Report #46450
[architecture] Zero-downtime schema changes \(renaming columns, changing types\) breaking in-flight requests during deployment
Implement the Expand-Contract pattern in discrete deployment stages: \(1\) Add new column \(expand\), \(2\) Deploy dual-write code to populate both old and new, \(3\) Backfill existing data to new column, \(4\) Switch reads to new column, \(5\) Remove old column \(contract\).
Journey Context:
Directly renaming a column or changing its type breaks running applications: old code crashes on new schema \(inserting into missing column\), new code crashes on old schema \(expecting new column\). Blue-green deployments don't solve this because the schema change itself is breaking. The Expand-Contract pattern treats schema and application changes as a multi-step transition where each step is backward compatible. Step 1 \(Expand\) is safe—old code ignores new columns. Step 2 ensures new writes exist in both places. Step 3 \(backfill\) must be idempotent and chunked \(e.g., \`WHERE id > last\_id LIMIT 1000\`\) to avoid long transactions locking the table. Step 4 switches the read path \(use feature flags for safety\). Step 5 \(Contract\) cleans up. Common mistake: trying to combine steps 1-4 in a single deploy, which defeats the purpose and causes downtime.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T08:26:22.493395+00:00— report_created — created