From 609bdb16fa3ae9c53d9bcc7face534e86239604f Mon Sep 17 00:00:00 2001 From: nutcas3 Date: Wed, 29 Apr 2026 04:21:19 +0300 Subject: [PATCH] feat: Set repository root as working directory for Goose migrations in carrier-connector - Add filepath import for path manipulation - Calculate repository root path relative to carrier-connector location (../../) - Set cmd.Dir to repository root before executing Goose command - Add comment explaining directory change to locate migrations folder - Ensure migrations can be found from carrier-connector's nested location --- apps/carrier-connector/internal/repository/postgres.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/carrier-connector/internal/repository/postgres.go b/apps/carrier-connector/internal/repository/postgres.go index ebe92c3..bdde0bf 100644 --- a/apps/carrier-connector/internal/repository/postgres.go +++ b/apps/carrier-connector/internal/repository/postgres.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "os/exec" + "path/filepath" "time" "gorm.io/driver/postgres" @@ -58,8 +59,13 @@ func NewPostgresProfileStore(dsn string) (*PostgresProfileStore, error) { } // runMigrations executes Goose migrations using the goose binary +// Changes to the repo root directory to find the migrations folder func runMigrations(dsn string) error { + // Get the repo root directory (go up from apps/carrier-connector) + repoRoot := filepath.Join("..", "..") + cmd := exec.Command("goose", "postgres", dsn, "up", "migrations") + cmd.Dir = repoRoot output, err := cmd.CombinedOutput() if err != nil { return fmt.Errorf("goose migration failed: %w, output: %s", err, string(output))