Skip to content

Conversation

@iAmLakshya
Copy link

@iAmLakshya iAmLakshya commented Dec 22, 2025

What kind of change does this PR introduce?

Feature (UX improvement)

What is the current behavior?

When running supabase db push, users see a generic prompt without any indication of which project they're pushing to:

  Do you want to push these migrations to the remote database?
   • 20240101000000_create_users.sql

  Finished supabase db push.

This can lead to accidentally pushing migrations to the wrong project when working with multiple Supabase projects. Users must rely on checking their .supabase/project-ref file or running supabase link to verify which project is linked.

What is the new behavior?

The command now fetches project details via the Management API and displays the project name and ID before prompting:

  Pushing to linked project: My App (abcdefghijklmnop)
  Do you want to push these migrations to the remote database?
   • 20240101000000_create_users.sql

  Finished supabase db push.

Scope:

  • Applies when pushing to a linked project (default --linked flag)
  • Does not apply when using --db-url (direct connection string) or --local flags, since there's no linked project in those cases

Files changed:

  • internal/db/push/push.go - Added projectRef parameter and printProjectInfo() function
  • cmd/db.go - Pass flags.ProjectRef to the push command
  • internal/bootstrap/bootstrap.go - Updated call signature (passes empty string for local bootstrap)
  • internal/db/push/push_test.go - Updated tests with new parameter

Additional context

This aligns with the existing behavior of supabase config push, which already displays project info before making changes:

Pushing config to project: abcdefghijklmnop

The implementation uses the existing V1GetProjectWithResponse API call (same pattern used in internal/link/link.go and internal/utils/tenant/database.go) to fetch the project name.

@iAmLakshya iAmLakshya requested a review from a team as a code owner December 22, 2025 02:13
)

func Run(ctx context.Context, dryRun, ignoreVersionMismatch bool, includeRoles, includeSeed bool, config pgconn.Config, fsys afero.Fs, options ...func(*pgx.ConnConfig)) error {
func Run(ctx context.Context, dryRun, ignoreVersionMismatch bool, includeRoles, includeSeed bool, projectRef string, config pgconn.Config, fsys afero.Fs, options ...func(*pgx.ConnConfig)) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The easiest change is to print the current project ref when parsing the --linked flag https://github.com/supabase/cli/blob/develop/internal/utils/flags/db_url.go#L83

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhh, totally missed that.

I've pushed changes addressing the above feedback. Let me know if they require further amendments.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 20467675161

Details

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • 7 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.02%) to 56.068%

Files with Coverage Reduction New Missed Lines %
internal/storage/rm/rm.go 2 80.61%
internal/gen/keys/keys.go 5 12.9%
Totals Coverage Status
Change from base Build 20465100323: -0.02%
Covered Lines: 6838
Relevant Lines: 12196

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants