Skip to content

Commit 9ab8670

Browse files
7ttpavallete
andauthored
fix: correct local db push text (#5280)
## TL;DR fixes `db push --local` so prompts and status messages refer to the local database ( as requested by users, was confusing ) ## ref - closes #4971 Co-authored-by: Andrew Valleteau <avallete@users.noreply.github.com>
1 parent e123b51 commit 9ab8670

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

  • apps/cli-go/internal/db/push

apps/cli-go/internal/db/push/push.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ func Run(ctx context.Context, dryRun, ignoreVersionMismatch bool, includeRoles,
2222
if dryRun {
2323
fmt.Fprintln(os.Stderr, "DRY RUN: migrations will *not* be pushed to the database.")
2424
}
25+
databaseName, statusTarget := "remote database", "Remote database"
26+
if utils.IsLocalDatabase(config) {
27+
databaseName, statusTarget = "local database", "Local database"
28+
}
2529
conn, err := utils.ConnectByConfig(ctx, config, options...)
2630
if err != nil {
2731
return err
@@ -51,7 +55,7 @@ func Run(ctx context.Context, dryRun, ignoreVersionMismatch bool, includeRoles,
5155
}
5256
}
5357
if len(pending) == 0 && len(seeds) == 0 && len(globals) == 0 {
54-
fmt.Println("Remote database is up to date.")
58+
fmt.Println(statusTarget + " is up to date.")
5559
return nil
5660
}
5761
// Push pending migrations
@@ -80,7 +84,7 @@ func Run(ctx context.Context, dryRun, ignoreVersionMismatch bool, includeRoles,
8084
}
8185
}
8286
if len(pending) > 0 {
83-
msg := fmt.Sprintf("Do you want to push these migrations to the remote database?\n%s\n", confirmPushAll(pending))
87+
msg := fmt.Sprintf("Do you want to push these migrations to the %s?\n%s\n", databaseName, confirmPushAll(pending))
8488
if shouldPush, err := utils.NewConsole().PromptYesNo(ctx, msg, true); err != nil {
8589
return err
8690
} else if !shouldPush {
@@ -99,7 +103,7 @@ func Run(ctx context.Context, dryRun, ignoreVersionMismatch bool, includeRoles,
99103
fmt.Fprintln(os.Stderr, "Schema migrations are up to date.")
100104
}
101105
if len(seeds) > 0 {
102-
msg := fmt.Sprintf("Do you want to seed the remote database with these files?\n%s\n", confirmSeedAll(seeds))
106+
msg := fmt.Sprintf("Do you want to seed the %s with these files?\n%s\n", databaseName, confirmSeedAll(seeds))
103107
if shouldPush, err := utils.NewConsole().PromptYesNo(ctx, msg, true); err != nil {
104108
return err
105109
} else if !shouldPush {

0 commit comments

Comments
 (0)