Prisma Migration Conflict After Schema Changes
After modifying your Prisma schema, migrations fail with 'Migration conflict' or 'Schema divergence detected' errors. Your database schema doesn't match the generated migrations.
This typically occurs when multiple developers create conflicting migrations or the local migration history doesn't match the database state.
Error Messages You Might See
Common Causes
- Two developers created different migrations with the same timestamp or conflicting changes
- Local migration files were deleted but database state remains
- Database already has the schema changes but Prisma migrations don't reflect this
- Merging branches with different migration histories
- Manual database changes made outside of Prisma migrations
How to Fix It
Resolve merge conflicts: If merging branches, check git history of migrations/ folder for conflicts. Resolve manually and recreate new migration.
Reset in development: For dev only: npx prisma migrate reset clears database and replays migrations from scratch.
Recovery in production: Use npx prisma migrate resolve --rolled-back migration_name to mark failed migration as rolled back, then create a new one.
Prevent conflicts: Use npx prisma migrate dev --name descriptive_name to create new migrations, commit them before pushing.
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
Can I delete migration files if I haven't deployed?
Only if your local database matches your schema. Reset with 'prisma migrate reset' first, then delete conflicts.
How do I handle migration conflicts in team development?
Establish a process: create descriptive migration names, merge feature branches before creating new migrations.
What's the difference between migrate dev and migrate deploy?
'migrate dev' is interactive, creates new migrations. 'migrate deploy' applies existing migrations to prod without prompts.