diff --git a/backend/Taskfile.yaml b/backend/Taskfile.yaml index d970d90..dd78b1d 100644 --- a/backend/Taskfile.yaml +++ b/backend/Taskfile.yaml @@ -62,3 +62,8 @@ tasks: desc: "Check for code common vulnerabilities" cmds: - govulncheck ./... + + migrate: + desc: "Migrate postgres" + cmds: + - go run ./cmd/migrate/ diff --git a/backend/cmd/migrate/main.go b/backend/cmd/migrate/main.go new file mode 100644 index 0000000..55876e6 --- /dev/null +++ b/backend/cmd/migrate/main.go @@ -0,0 +1,25 @@ +package main + +import ( + "log" + + "github.com/taldoflemis/brain.test/config" + "github.com/taldoflemis/brain.test/internal/adapters/driven/postgres" +) + +func main() { + koanf := config.NewKoanfson() + err := koanf.LoadFromJSON("config.json") + if err != nil { + log.Fatal(err) + } + pgCfg, err := config.NewPostgresConfig() + if err != nil { + log.Fatal(err) + } + log.Print(pgCfg.Database) + + connStr := postgres.GenerateConnectionString(pgCfg) + log.Print(connStr) + postgres.Migrate(connStr, "internal/adapters/driven/postgres/migrations/") +} diff --git a/backend/config.json b/backend/config.json index a2c8e97..03ac5ae 100644 --- a/backend/config.json +++ b/backend/config.json @@ -19,8 +19,8 @@ "postgres": { "host": "localhost", "port": 5432, - "user": "postgres", + "user": "adminson", "password": "password", - "database": "postgres" + "database": "brain" } }