Skip to content
Latchkey

Prisma "Drift detected: your database schema is not in sync" in CI

Drift means the actual database schema differs from what the applied migrations describe. Something changed the database outside of Prisma Migrate, so the recorded history no longer matches reality.

What this error means

A migrate step (dev or a status check) reports "Drift detected: Your database schema is not in sync with your migration history" and lists the differing objects.

Prisma
Drift detected: Your database schema is not in sync with your migration history.

The following is a summary of the differences between the expected database schema given your migrations files, and the actual schema of the database.
[+] Added tables
  - audit_log

Common causes

Manual changes outside migrations

A table, column, or index was created directly on the database, so it is not represented in any migration.

A different migration set applied to a shared DB

Another branch or environment applied migrations to the same database, leaving it out of sync with this branch history.

How to fix it

Reconcile with a migration

  1. Capture the out-of-band change as a new migration, or revert it.
  2. For a disposable CI database, reset so it matches history exactly.
  3. Never hand-edit shared databases outside Prisma Migrate.
Terminal
# ephemeral CI DB: make it match migration history
npx prisma migrate reset --force

Detect drift as a gate

Run a status check so drift fails fast instead of surprising a later deploy.

Terminal
npx prisma migrate status

How to prevent it

  • Make all schema changes through Prisma Migrate.
  • Use a fresh database per CI run to avoid shared drift.
  • Add a migrate status check to catch drift early.

Related guides

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