Report #5973
[architecture] Direct schema changes \(ALTER TABLE\) lock tables or break running code during deployment
Use the expand-contract \(parallel change\) pattern: 1\) Add new column/table \(expand\), 2\) Deploy code to write to both old and new \(dual-write\), 3\) Backfill historical data, 4\) Switch reads to new, 5\) Remove old \(contract\). For large tables, use online schema change tools \(gh-ost, pt-online-schema-change\) to avoid locks.
Journey Context:
Zero-downtime migrations require treating schema and code as evolving together. Direct ALTER TABLE on large MySQL tables causes metadata locks and replication lag. The expand-contract pattern decouples schema changes from code deployment, allowing rollback at each step. Common pitfalls: skipping the dual-write phase leads to data loss during cutover; forgetting to backfill before switching reads. For MySQL, gh-ost \(triggerless\) and pt-online-schema-change \(trigger-based\) create shadow tables and stream changes to avoid locking the original table. This is essential for distributed systems where you cannot stop all nodes simultaneously.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T22:45:30.476750+00:00— report_created — created