Supabase preview environments per PR: branch, migrate, test, merge, delete
Shows how to fix supabase preview environments per PR: branch, migrate, test, merge, delete. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
Apply the PR's migrations to it. Run CI against the branch database: migrations apply cleanly, the test suite passes, and the app's critical paths work end to end.
Steps
- Application preview deployments without a matching database preview prove nothing about migrations. Pair them: one Supabase branch per pull request, wired to that PR's preview deployment.
- On PR open, create a Supabase branch. Apply the PR's migrations to it. Point the PR's preview deployment at the branch credentials.
- Seed the branch with production-shaped data (anonymized). An empty database passes tests that real data would fail, especially around constraints and RLS.
- Run CI against the branch database: migrations apply cleanly, the test suite passes, and the app's critical paths work end to end.
- Review the migration diff as part of the PR review. The branch proves it applies; the review proves it is correct and reversible.
- On merge, apply the migrations to production and delete the branch. Stale branches accumulate data and cost; the merge is the trigger for cleanup.
When to use
You are seeing this: Application preview deployments without a matching database preview prove nothing about migrations. Use this skill when you run into "Supabase preview environments per PR: branch, migrate, test, merge, delete".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.