Prisma error P3001 (Migration Requires Destructive Changes) explained: what it means, why it happens, and how to fix it — with copy-paste code examples.
Read the warning details: Prisma lists exactly which table/column will be dropped or altered. If that does not apply, for local dev: confirm the destructive change deliberately, or fix the schema and regenerate — the full checklist is below.
Error code: P3001
Official name: Migration Requires Destructive Changes
Service: Prisma
Migration possible with destructive changes and possible data loss: {migration_engine_destructive_details}
npx prisma migrate dev --create-only
npx prisma migrate diff \
--from-migrations prisma/migrations \
--to-schema-datamodel prisma/schema.prisma --script
Generates the migration SQL without applying it so you can review exactly what will be dropped or changed.
model User {
id Int @id @default(autoincrement())
legacy String? // step 1: add as nullable
// step 3 (later): delete this field
}
Expand, backfill, then contract. Destructive drops happen only after data has moved.
Review generated SQL before accepting a destructive migration.
npx prisma migrate dev --create-only
cat prisma/migrations/*_/migration.sql
npx prisma migrate dev
Gate production deploys on a review of the diff between the last applied migration and the target schema.
npx prisma migrate diff \
--from-migrations prisma/migrations \
--to-schema-datamodel prisma/schema.prisma \
--script
Keep destructive schema changes in dedicated migrations with data backfills so deploys stay reversible.
# migration N+1: add new_col (nullable)
# migration N+2: backfill data (SQL UPDATE)
# migration N+3: drop old_col
Most often this happens when removing a column, table or enum value that is still in use, or when changing a column type (e.g. String to Int) that requires data conversion or data loss.
Read the warning details: Prisma lists exactly which table/column will be dropped or altered.
This page documents fixes for: prisma-cli, github-actions, nestjs.
Recommendations are editorial — DB Error Reference takes no payment or affiliate fees for tool listings.
This page is based on the official Prisma documentation linked below and adds practical troubleshooting guidance on top.