Skip to content
Latchkey

Prisma "Drift detected" schema out of sync in CI

Prisma compared the live database against the state implied by your migration history and they differ. prisma migrate dev reports drift and proposes a reset, which in CI shows up as an unexpected prompt or a destructive plan.

What this error means

prisma migrate dev prints "Drift detected: Your database schema is not in sync with your migration history" and lists the differences, then wants to reset the database.

prisma output
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...
[+] Added table `audit_log`

Common causes

Schema changed outside of migrations

A table, column, or index was added or altered directly in the database (or by another tool), so the real schema no longer matches the migration history.

Using migrate dev against a shared or seeded database

migrate dev is for development and expects to own the database; pointing it at a pre-populated CI database makes it see the existing objects as drift.

How to fix it

Use migrate deploy in CI, not migrate dev

migrate deploy applies pending migrations without drift detection or resets, which is the correct command for CI and production.

Terminal
npx prisma migrate deploy

Reconcile real drift with a new migration

  1. Identify the out-of-band change from the drift summary.
  2. Either revert the manual change, or capture it in a new migration with prisma migrate dev --name capture_drift on a development database.
  3. Commit the new migration so history matches reality everywhere.

How to prevent it

  • Reserve migrate dev for local development and run migrate deploy in CI.
  • Never change the schema outside the migration workflow.
  • Start CI migrations from a clean database so there is nothing to drift from.

Frequently asked questions

What causes "Prisma "Drift detected""?
A table, column, or index was added or altered directly in the database (or by another tool), so the real schema no longer matches the migration history.
How do I fix Prisma "Drift detected"?
migrate deploy applies pending migrations without drift detection or resets, which is the correct command for CI and production.

Related guides

References

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