Skip to content
Latchkey

Supabase migration drift ("found local migration ... not applied") in CI

Drift means the applied migration history on the remote database and the files in supabase/migrations disagree. This happens when someone changed the schema in the dashboard or applied a migration that was later removed locally.

What this error means

A push or diff step reports "Remote migration versions not found in local migrations directory" or "found local migration files to be inserted before the last migration".

supabase
The remote database's migration history does not match local files in
supabase/migrations directory.
Remote migration versions not found in local migrations directory: 20260601000000

Common causes

Schema changed outside migrations

A dashboard edit or a manual SQL change altered the remote schema without a corresponding migration file, so the histories diverge.

A local migration was removed or reordered

Deleting or renaming an applied migration file makes the local set inconsistent with what the remote recorded.

How to fix it

Capture the drift into a migration

  1. Diff the remote against local to see the untracked change.
  2. Generate a migration that records it, or repair the history.
  3. Commit the migration so CI and remote agree going forward.
Terminal
supabase db diff --linked --file capture_drift

Repair the migration history

Mark the out-of-band version as applied (or reverted) so the recorded history matches reality.

Terminal
supabase migration repair --status reverted 20260601000000

How to prevent it

  • Make schema changes only through committed migrations.
  • Avoid editing the schema in the dashboard for environments CI manages.
  • Never delete or reorder migration files that have been applied.

Frequently asked questions

What causes "Supabase migration drift"?
A dashboard edit or a manual SQL change altered the remote schema without a corresponding migration file, so the histories diverge.
How do I fix Supabase migration drift?
Capture the drift into a migration

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card