Zero-Downtime DB Migrations
Studies in this cluster, in series order. Each one keeps its own URL.
Databases
Indexes, isolation, storage engines, shard and partition keys, and zero-downtime migrations you can ship without a maintenance window.
Zero-Downtime DB Migrations
6 studies- 1.Zero-Downtime Database Migrations — Expand/Contract, Dual Write & Online DDLZero-downtime migrations change schema and data paths without taking the app offline. Expand first and contract only after every reader and writer is gone. Online DDL bounds lock time. Dual-write, an idempotent backfill, and a feature-flag rollback cover moves to a new table or store.
- 2.Expand/Contract Pattern — Additive Schema Changes Without DowntimeExpand/contract keeps old and new code running on one schema: add the new shape, migrate traffic and data while both exist, and drop the old shape only after every reader and writer is gone. A rename is a new column plus dual-write, not one RENAME in the same deploy.
- 3.Online DDL — Locks, CONCURRENTLY, gh-ost & pt-oscOnline DDL applies schema changes while the database serves traffic, with locks held only for brief metadata steps. Postgres has CREATE INDEX CONCURRENTLY and a leftover INVALID index on failure. MySQL has INSTANT, INPLACE, and COPY. Hot rewrites move to gh-ost (binlog) or pt-osc (triggers).
- 4.Dual Write / Dual Read — Migrating Data Paths SafelyWhen rows must live in a new table or store, dual-write keeps both paths updated and dual-read flips traffic. The order is write-both/read-old, shadow compare, read-new, then write-new-only. Partial failure, ordering, and idempotency dominate. An outbox makes the second write durable intent.
- 5.Backfills & Reconciliation — Idempotent Jobs, Checksums, Shadow ReadsBackfills copy historical rows while dual-write covers live traffic. Use keyset pages, a persisted resume token, and a lag gate. Prove the copy with chunk checksums and shadow reads. A matching row count with a failing checksum is not permission to cut over.
- 6.Rollback, Feature Flags & Cutover — Instant Reverse Without Data LossCutover is when users start depending on the new path. Rollback flips the read flag in seconds, which only works while the old path still exists and dual-write kept it current. DROP COLUMN, destructive casts, and write-new-only after the old path has drained are the irreversible zone.