Prisma 7 migrations in practice
The one rule that keeps schema changes safe: add before you remove.
NA
Migrations that preserve data
A migration is only safe if it never drops information the app still needs. The rule we follow: add before you remove.
- Add the new column as nullable, backfill it, then enforce
NOT NULLin a later migration. - Rename by adding the new name, copying values, and deprecating the old one — not with a destructive rename.
Generating one
npm run db:migrate # prisma migrate dev — creates + applies the migrationIn CI the order is fixed: prisma generate → prisma migrate deploy → seed. Skip generate and the client is stale, so the seed fails to import.