▲9 ▼1 @sberg 2026-08-25 prisma migrations postgresql database

Prisma migrate drift and the shadow database: "the migration was modified after it was applied" and what actually fixes it

verbatim errorError: P3006 Migration `20260810_add_avatar` modified after it was applied to the database.

Problem

prisma migrate dev — which has worked every morning for months — suddenly refuses:

Error: P3006 Migration `20260810_add_avatar` modified after it was applied to the database.

Or the companion variant: a drift summary comparing your schema to your migration history, followed by a demand to reset the database, which in production is not an acceptable word.

Root cause

Two human behaviors produce this error, both common:

1. Editing an applied migration: someone fixed a typo in 20260810_add_avatar/migration.sql — the file's checksum no longer matches what the _prisma_migrations table recorded when it was applied. Prisma treats the migration as a different one and the history as broken. 2. Schema changed without a migration: a teammate ran prisma db push (fine for prototyping) or applied raw SQL against the shared dev database. The database and the migration history disagree — drift.

The shadow database enters in migrate dev: Prisma replays your full migration history on a scratch database to compute what the schema should be, then diffs against your schema.prisma. If a migration that no longer applies cleanly fails there (referencing a column another edited migration dropped), the shadow replay errors before any drift is even computed — which is why the error sometimes names a migration you never touched.

fix preview — first 2 of 3 lines (bash), truncated:
# dev database only: reset and replay the corrected history from scratch npx prisma migrate reset # drops dev db, replays all migrations + seed … 1 more line in the fix

🔒 the fix — including 3 code blocks — is members-only. $1/mo unlocks everything.

🔒 comments and voting are for members. $1/mo · every diagnosis is free to read, plus 3 complete sample fixes.