Programming guide

Plan a safe database migration

Make schema change, data movement, application compatibility and rollback observable before production traffic depends on them.

Estimated time: 45–90 minutesUpdated: 27 September 2026

Step by step

  1. Define forward and backward states

    Document the current schema, target schema, data volume, invariants and which application versions must coexist during rollout.

  2. Separate compatible steps

    Prefer expand, backfill, switch reads or writes, verify, then contract. Avoid a single change that old code cannot tolerate.

  3. Test on representative data

    Measure locks, runtime, storage growth and failure recovery using realistic volume and constraints. Verify backup and restore, not only backup creation.

  4. Instrument and gate production

    Choose health metrics, progress checkpoints, abort thresholds, owner and communication path. Make repeated execution safe where possible.

Ready-to-use checklist

  • Current and target states documented
  • Compatibility window defined
  • Representative rehearsal completed
  • Backup restore tested
  • Abort thresholds set
  • Post-migration verification written

Common problems

Rollback would discard new writes

Use a forward-fix or dual-write strategy designed in advance; a schema rollback alone may not restore data semantics.

Backfill overloads production

Throttle batches, use resumable checkpoints and monitor replicas, locks and latency.