diff --git a/cmd/migrate/main.go b/cmd/migrate/main.go index 4559912..dad9696 100644 --- a/cmd/migrate/main.go +++ b/cmd/migrate/main.go @@ -55,8 +55,16 @@ func main() { os.Exit(1) return } + machineID := os.Getenv("PG_MACHINE_ID") - targetURI := fmt.Sprintf("postgres://postgres:%s@%s.internal:5432", operatorPass, appName) + appDomain := appName + ".internal" + if machineID != "" { + appDomain = machineID + ".vm." + appDomain + } else { + log.Println("[warn] PG_MACHINE_ID was not specified, falling back to resolving from app name") + } + + targetURI := fmt.Sprintf("postgres://postgres:%s@%s:5432", operatorPass, appDomain) opts := migrationOpts{ sourceURI: sourceURI,