backend patterns
Prisma Migrations Without Surprising Production
Expand-contract patterns, backward-compatible schema changes, and when to reach for raw SQL in Prisma projects.
2025-02-28 · 1 min read
Expand-contract
Never drop a column in the same deploy that stops reading it. The safe sequence:
- Add new column (nullable)
- Dual-write in application code
- Backfill data
- Switch reads to new column
- Remove old column in a later migration
Prisma-specific tips
- Use
prisma migrate deployin CI, notdb push, for production. - Review generated SQL for locking behavior on large tables.
- Keep migrations small — one logical change per migration.
When ORM isn't enough
For index creation on huge tables, use CREATE INDEX CONCURRENTLY via $executeRaw in a dedicated migration step.