GuidesUpdated

Review an AI-generated Supabase migration before deployment

Check the target project, schema diff, existing data, RLS, staging result and restore option before an agent-written migration reaches production.

On this page

An agent can write valid SQL that's still wrong for your live database. Say a PR adds an optional `archived_at` field to project notes. It runs locally, but an unexpected drop, broad policy, old data value or wrong linked project could change production. Review the migration as a data change with a target and a recovery plan.

Canopy review workspace with an agent's changed files and project branch
Canopy review workspace with an agent's changed files and project branch

Identify the database the agent can reach

Before applying anything, record the Git branch, the Supabase project reference or local endpoint, the environment variables in use, and who can run migrations. A local site can point at a remote database, so the screen doesn't prove the target. Supabase recommends separate staging and production projects. Keep production credentials out of exploratory agent sessions. In Canopy, check the checkout, service commands and terminal output together.

A release path to check against your own project IDs and connections.
StageDatabase targetEvidence before proceeding
Local trialDisposable local Supabase stackFresh migration applies; seeded behavior passes
StagingSeparate staging projectExisting-like data and app behavior survive
ProductionExplicit production projectApproved diff, backup option, release owner, and monitoring

Read the SQL against the task

For `archived_at`, a nullable column may be all you need. Ask why the diff also drops a column, replaces a table, changes a default, updates every row or edits an RLS policy. Supabase says schema changes belong in migration files tested locally. Review the SQL and its order, not the agent's summary or a green build. Check existing notes, empty values and clients on the old app version.

  • List every table, column, index, function, trigger, grant and policy changed.
  • For each update or delete, state which rows it touches.
  • If old and new app versions can't coexist, plan an ordered rollout.

Run it on disposable data, then staging

Apply the migration to a fresh local database from the migration history and run the feature checks. Then test on staging with realistic, non-sensitive rows; a blank database hides conflicts with old data. Supabase's guide shows CI testing PRs and releasing to staging first. Record the schema, sample row counts and behavior checked: an existing note stays readable, and another team can't see it.

  • Check both the new archive behavior and the unchanged read and edit flow.
  • Test a null or legacy value with known fixtures.
  • Keep test and production projects and keys clearly separate.

Confirm recovery before you pick a release window

Find out which backup or point-in-time recovery option the production project has, how recent the last restore point is, and who can restore. Availability depends on plan: free projects may need a manual export, and a restore can take the project offline. Backups exclude Storage objects. A Git revert isn't a database restore, and old app code won't undo destroyed data. If recovery is unclear, stop until someone owns it.

  • Record backup time, retention, data-loss window and restore owner.
  • For a live paid product, identify writes that could arrive during rollback or restore.
  • Rehearse restores on a disposable project, not production.

Release and inspect the final state

The responsible owner approves the exact migration and target. Supabase recommends running production migrations from CI/CD, not a laptop. Afterward, check the recorded version, reads and writes, RLS denial cases and logs, and compare the production schema with the reviewed PR. If the agent later changes the SQL, repeat the affected checks.

  • Record the migration version and project reference, never credentials.
  • Watch for errors and unexpected row counts after rollout.
  • Name the reviewer, deployment owner and recovery owner.

Copyable resources

Migration review record

Fill in project references and results, never passwords or service-role keys.

PR and latest commit: [ ]
Requested data behavior: [ ]
Migration files and affected objects: [ ]
Local project/branch and migration result: [ ]
Staging project and realistic-data result: [ ]
Existing rows checked before/after: [ ]
RLS and cross-user test if policy changed: [ ]
Old app / new schema coexistence: [ ]
Production project reference confirmed by: [ ]
Backup or PITR option, latest restore point, restore owner: [ ]
Approved production path and window: [ ]
Post-deploy version, app checks, logs, owner: [ ]

Frequently asked questions

If the migration ran locally, is it ready for production?

Not yet. Test with realistic existing data and confirm the production target, app behavior, access rules and recovery option.

Can I revert the PR to undo a bad migration?

No. Reverting app code doesn't restore deleted or transformed data. Plan a database-specific correction or restore with the responsible owner.

Does Supabase always have a recent automatic backup?

No. Availability and retention depend on the project's plan and settings. Check the actual project and restore point; a local reset or Git history isn't a production backup.

Can an agent run the production migration for me?

That's a repository and operations decision. Review the exact SQL, target, access, staging result and recovery plan before granting production credentials or a release pipeline.

More questions and answers →

Sources and further reading