mirror of
https://github.com/andwati/telecom-platform.git
synced 2026-10-18 11:02:54 +00:00
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:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user