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
This commit is contained in:
nutcas3
2026-04-29 04:21:19 +03:00
parent 898e58201f
commit 609bdb16fa
@@ -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))