• use prisma migrate dev locally to evolve your schema
  • use prisma migrate deploy in staging / production env to apply those changes safely and incrementally.

How Prisma tracks migrations

When running prisma migrate deploy in production

  • reads prisma/migrations folders.
  • checks the _prisma_migrations table in production (or env) db.
  • applies any new migrations that haven’t been run yet

Manual Consolidate

Tip

  • It’s only safe to run when in early development and no production db exists.
  • Single developer and resetting all env together.
  • Okay with resetting the database and loosing all data.

Resets database (will erase data)

npx prisma migrate reset

Delete all migrations

rm prisma\migrations -r

Create fresh baseline migration

npx prisma migrate dev --name baseline

Warning

Do not do this on production if other env rely on existing migration history.