Skip to content

fix(cli): stop suggesting repair --status applied for unpushed migrations - #7893

Merged
Prashansa-K merged 4 commits into
developfrom
fix/db-pull-unsafe-repair-suggestion
Dec 2, 2026
Merged

Prashansa-K merged 4 commits into
developfrom
fix/db-pull-unsafe-repair-suggestion

Conversation

@Prashansa-K

Copy link
Copy Markdown
Contributor

Fixes CLI-3310.

  • `db pull` migration-history conflicts now suggest `supabase db push --dry-run` then `supabase db push` for local-only versions, adding `--include-all` when a local version is older than the latest version present on both sides. `repair --status applied` stays only as an explicit second option for SQL confirmed as already applied. `--status reverted` lines for remote-only versions are unchanged.
  • `db reset --last` help now states that the last n local migrations are rolled back, not applied.

🤖 Generated with Claude Code

Prashansa-K and others added 2 commits December 1, 2026 12:04
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ify reset --last

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@Prashansa-K
Prashansa-K requested a review from a team as a code owner December 1, 2026 06:37
@Prashansa-K
Prashansa-K requested a review from avallete December 1, 2026 06:37
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

CLI benchmark (Lightweight Commands): no changes found

Commit d7d29cc against develop at 00782d7 · 10 runs each · report only, never blocks merging

Command Workload Before After Change
supabase --version version 161 ms 163 ms no real change
supabase --help help 218 ms 200 ms no real change (-8%, within normal variation)
supabase init init 165 ms 163 ms no real change
supabase migration new bench migration-new 175 ms 172 ms no real change
supabase config convert config-convert 176 ms 173 ms no real change
supabase config validate config-validate 189 ms 198 ms no real change
supabase gen types --lang typescript --project-id replayfixtureprojref gen-types 201 ms 199 ms no real change
supabase projects list projects-list 179 ms 181 ms no real change
supabase functions list --project-ref replayfixtureprojref functions-list 190 ms 188 ms no real change

API calls: unchanged for all 9 commands.

Binary size: 135.7 MB, up 4.0 KB from 135.7 MB.

Details: timing ranges, API calls per command, slowest phases

Timing ranges

Command Workload Before range After range Change Verdict
supabase --version version 156-171 ms 154-175 ms +2 ms (+2%) within noise
supabase --help help 162-238 ms 161-249 ms -18 ms (-8%) within noise
supabase init init 158-179 ms 159-183 ms -2 ms (-1%) within noise
supabase migration new bench migration-new 164-208 ms 166-280 ms -3 ms (-2%) within noise
supabase config convert config-convert 170-192 ms 169-192 ms -4 ms (-2%) within noise
supabase config validate config-validate 181-197 ms 182-211 ms +9 ms (+5%) within noise
supabase gen types --lang typescript --project-id replayfixtureprojref gen-types 194-207 ms 192-209 ms -2 ms (-1%) within noise
supabase projects list projects-list 177-187 ms 177-187 ms +2 ms (+1%) within noise
supabase functions list --project-ref replayfixtureprojref functions-list 185-205 ms 182-199 ms -2 ms (-1%) within noise

API calls per command

Command Workload Before After Endpoint changes
supabase --version version 0 0
supabase --help help 0 0
supabase init init 0 0
supabase migration new bench migration-new 0 0
supabase config convert config-convert 0 0
supabase config validate config-validate 0 0
supabase gen types --lang typescript --project-id replayfixtureprojref gen-types 2 2
supabase projects list projects-list 1 1
supabase functions list --project-ref replayfixtureprojref functions-list 2 2

Slowest phases

No command moved beyond noise, so there are no phase deltas.

Workflow run

Comment /bench to run the lightweight benchmark (this comment) again on the latest commit, or /bench full to also run the integration-heavy benchmark, which posts in its own comment.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🤖 AI Review

CLI reference prose guidance: snapshot supabase/supabase@57d40e4 supplied to reviewers (advisory, not a style pass).

The new migration recovery hint can rerun SQL that already ran, direct a push at a different database or project, and update Vault secrets that the dry run does not preview. It also puts live migration-history edits before the push preview. Both independent reviews were available. Static inspection confirmed these risks and found that the new db reset --last help overstates what reset skips when migration versions have mixed widths.

Findings

Severity Location Category Sources Claim
🟠 MAJOR apps/cli/src/command-internal/migration-history.ts:249 migration-safety codex The suggested push can rerun SQL for migrations that already ran outside the migration history.
🟠 MAJOR apps/cli/src/command-internal/migration-history.ts:248 migration-safety codex The new push commands can target a different database or read a different checkout when the original pull used --stack or --workdir.
🟡 MINOR apps/cli/src/command-internal/migration-history.ts:239 migration-safety codex The new recovery sequence directs users to delete target-only history entries before showing a push preview, even when those entries represent valid applied migrations.
🟡 MINOR apps/cli/src/command-internal/migration-history.ts:253 correctness claude+codex The hint tells users to verify SQL on a remote database even when the suggested repair will mark it applied on the local database.
🟡 MINOR apps/cli/src/command-internal/migration-history.ts:248 migration-safety codex The suggested live push can update configured Vault secrets even though the hint describes running migration SQL and the dry run does not list those updates.
🟡 MINOR apps/cli/src/commands/db/reset/reset.command.ts:40 correctness codex The new help promises to skip the last n local migrations, but --last can replay every migration when version IDs have mixed widths.
⚪ NIT apps/cli/src/command-internal/migration-history.unit.test.ts:245 test-quality codex The reconciliation and formatter tests both assert the dry-run command for the same kind of historical gap.
⚪ NIT apps/cli/src/command-internal/migration-history.unit.test.ts:232 test-quality codex The command-ordering fixture treats version 111 as both target-only and matched.
⚪ NIT apps/cli/src/commands/db/reset/reset.command.ts:40 docs-style codex The --last description states the intended migration cutoff twice.
⚪ NIT apps/cli/src/commands/migration/down/down.command.ts:24 consistency claude db reset --last now explains which migrations it skips, while migration down --last still leaves it unclear whether n counts versions to keep or revert.

Findings outside the diff

  • ⚪ NIT apps/cli/src/commands/migration/down/down.command.ts:24 — db reset --last now explains which migrations it skips, while migration down --last still leaves it unclear whether n counts versions to keep or revert.

Stats

Claude findings: 2 · Codex findings: 6 · Confirmed: 10 · Refuted: 0 · Uncertain: 0


Models: claude-opus-5-5 + gpt-6.2-sol · Trigger: auto · Workflow run

This review runs once per PR. A maintainer can request another with a /ai-review comment.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@avallete avallete left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ran this against a throwaway staging project: a local-only version newer than the tip gets a plain db push, one older than a matched version gets --include-all, and the suggested commands work as printed. 👍

One small gap: flagsForTarget returns "" for local targets, so after db pull --stack feature the hint prints a bare db push / migration repair, which lands on the default stack rather than feature. The repair lines already had this, so not a blocker, but since you're adding a push line it might be worth carrying --stack <name> through, with a test for it.

Nit: if someone restores a newer remote-only file as the hint suggests, the push then needs --include-all. db push already says so itself, so fine to leave.

@avallete avallete left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, the notes above are non-blocking.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@Prashansa-K
Prashansa-K added this pull request to the merge queue Dec 2, 2026
@Prashansa-K Prashansa-K self-assigned this Dec 2, 2026
Merged via the queue into develop with commit 0dc219f Dec 2, 2026
49 checks passed
@Prashansa-K
Prashansa-K deleted the fix/db-pull-unsafe-repair-suggestion branch December 2, 2026 02:30
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.

2 participants