Test a destructive migration on a database branch before applying to prod
When to use: You have a migration that drops a column or backfills millions of rows, and you want to dry-run on a real-data branch first.
Prerequisites
- Supabase Pro plan or higher — Branching is gated to paid plans
- Personal access token — supabase.com/dashboard/account/tokens — scope to your org
Flow
-
Create a branch from prodCreate a database branch named 'test-drop-legacy-col' off the main branch in project <ref>. Wait for it to be ready.✓ Copied→ Branch created with its own connection string
-
Run the migration on the branchApply the following migration on the new branch: <paste SQL>. Report rows affected and any errors.✓ Copied→ Migration runs; row counts visible
-
Verify and either promote or discardRun sanity SELECTs on the branch (top 10 rows of affected tables, NULL counts on changed columns). If it looks good, tell me and I'll promote; if not, delete the branch.✓ Copied→ Verification output, then explicit human go/no-go
Outcome: Migration validated against real data shape before it touches prod.
Pitfalls
- Branches don't have prod's exact data — they're a snapshot at branch-create time — Note the snapshot timestamp; if your migration is sensitive to recent rows, branch as close to apply time as possible
- Branch creation costs compute hours — Always delete the branch after testing; abandoned branches accumulate billing