Prisma Migration Failed - Schema Mismatch
Running `prisma migrate dev` fails with schema validation errors. The app can't sync with the database schema or migrations won't apply.
You see errors about 'Migration already applied', schema divergence, or the database being in a bad state preventing any migrations.
Error Messages You Might See
Common Causes
- Uncommitted changes in migration history
- Database schema modified outside of Prisma (manual SQL)
- Migration file corrupted or contains invalid SQL
- Trying to add non-nullable column without default value
- Foreign key constraints preventing schema changes
How to Fix It
Check migration status: npx prisma migrate status
Reset database in development (careful!): npx prisma migrate reset
For new non-nullable fields, add with default: @default(uuid()) or @default(now())
Review migrations folder and ensure all files are valid SQL
Real developers can help you.
You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.
Get HelpFrequently Asked Questions
Is it safe to reset the database in production?
NEVER use prisma migrate reset in production. Use npx prisma migrate deploy instead
How do I add a column without losing data?
Add column with @db.String? (nullable), then update existing records, then make non-nullable
What if a migration is stuck?
Check prisma_migrations table in database. Manually mark it as resolved if data is correct: UPDATE _prisma_migrations SET finished_at = NOW()