Report #71354
[architecture] Zero-downtime schema changes \(renaming columns, changing types\) without breaking running code
Use the expand-contract pattern: 1\) Add new column \(expand\), 2\) Write to both old and new columns \(dual-write\), 3\) Backfill historical data, 4\) Switch reads to new column, 5\) Remove old column \(contract\). Never rename in-place.
Journey Context:
Direct ALTER TABLE on large tables locks the table for seconds to hours \(MySQL rebuilds the table; Postgres rewrites the table for certain alters\). Blue-green deployments fail if the new code expects a column that doesn't exist yet. The expand-contract pattern treats schema like API versioning: maintain backward compatibility during transition. Common failures: forgetting to backfill \(nulls for old rows\), not handling rollback \(if you need to revert code, the old column must still be writable\), and race conditions during the cutover. Tools like gh-ost \(MySQL\) or pg-online-schema-change automate the backfill phase without locks. The tradeoff is temporary storage overhead \(duplicate columns\) and code complexity \(dual-write logic must be idempotent\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T02:20:38.535882+00:00— report_created — created