Report #15336
[architecture] Zero-downtime database schema changes with data integrity risks or requiring application locks
Implement the Expand-Contract pattern \(Parallel Change\): Phase 1 deploy code writing to both old and new schema \(double-write\) while reading from old. Phase 2 backfill existing data to new schema. Phase 3 switch reads to new schema. Phase 4 remove old write path and drop old column.
Journey Context:
Direct \`ALTER TABLE\` on large tables acquires exclusive locks \(in MySQL with copy algorithms, or PostgreSQL for \`DROP COLUMN\` rewrites\), causing downtime. Simple rename operations break in-flight requests that have the old schema cached. The Expand-Contract pattern decouples schema changes from code deployment through intermediate states where both schemas coexist. Double-writing ensures zero data loss during the transition. Backfills must be chunked and idempotent to avoid locking. Common mistake: attempting to backfill before deploying double-write code, creating a window where new writes are lost, or dropping the old column before verifying the read path handles nulls/defaults correctly.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T23:48:56.712319+00:00— report_created — created