Report #35099
[architecture] Directly modifying database columns or tables causes downtime or data loss during deployments
Use the Expand/Contract pattern: 1\) Deploy code that writes to both old and new schema \(expand\), 2\) Backfill data, 3\) Switch reads to new schema, 4\) Remove old schema writes \(contract\)
Journey Context:
Rolling deployments run old and new code simultaneously. If new code renames a column \(ALTER TABLE users RENAME COLUMN name TO full\_name\), old code instances fail immediately because they still reference 'name'. Similarly, dropping a column that old code reads causes errors. Direct schema changes also often require ACCESS EXCLUSIVE locks that block reads and writes. The Expand/Contract pattern treats schema like an API with versioning. Phase 1 \(Expand\): Add the new column/table \(new schema\) while keeping the old. Deploy code that writes to both old and new locations \(dual-write\), but still reads from old. Phase 2: Backfill historical data into the new schema if needed \(idempotent updates\). Phase 3: Switch reads to the new schema \(cutover\), still writing to both for safety. Phase 4 \(Contract\): Once stable, stop writing to the old schema and eventually drop it. Tradeoffs: Requires multiple deployment cycles \(days/weeks\); temporarily doubles storage; application code complexity \(feature flags needed to control read paths\); temporary eventual consistency between old and new stores during backfill. This is the only safe method for large-scale online migrations in distributed systems.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T13:22:53.525610+00:00— report_created — created