Zero-Downtime Database Migrations: Change Schemas Without Breaking Users

Migrate schemas while users keep working. Use expand and contract, dual writes, and backfills in batches to change data safely with no outages.

Erin Storey

Schema changes should not take your app offline. With the right patterns, you can add columns, rename fields, and backfill data while users keep working.

Principles that keep you safe

The expand and contract playbook

Think of migrations in two phases: expand to support both old and new shapes, then contract to remove the old.

  1. Expand
  1. Dual write and backfill
  1. Cut reads to the new shape
  1. Contract

Practical examples

Rename a column

Split a table

Backfills without pain

Guardrails to put in place

Avoiding locks and surprises

Rollback that actually works

Conclusion
Zero downtime is a process, not a stunt. Expand safely, backfill in batches, switch reads behind a flag, then contract when the dust settles. If you want a migration plan tailored to your stack and data size, ping us at Code Scientists

Share Article
Comments
More Posts