LLevelUp
0
← Back to topic

Database Migrations

Migrations change database schema over time. Safe deploys consider both old and new app versions during rollout.

Safer sequence for a column rename:

  1. Add new column.
  2. Write to both columns.
  3. Backfill data.
  4. Read from new column.
  5. Drop old column later.

CAUTION

Destructive migrations need rollback and backup plans. Dropping data is not like reverting code.

Further Learning

  • “expand contract database migrations” — zero-downtime schema changes
  • “Prisma migrations production” — ORM migration flow
  • “database migration rollback strategy” — recovery planning