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.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →