Report #99669
[architecture] How do I rename a column or change a constraint without taking the application offline?
Use the expand/contract pattern: first add the new schema while keeping the old; then deploy code that writes to both and reads from the old; backfill existing data; switch reads to the new; finally drop the old schema in a later migration.
Journey Context:
Direct ALTER TABLE changes that lock tables or rename columns break running code that still references the old shape. Expand/contract decouples schema changes from code changes so each deploy is backward-compatible with the previous version. The classic failure is renaming a column in one step: queries fail between migration completion and the new code starting. By adding the new shape, dual-writing, backfilling, and only then removing the old, every deploy can roll back safely. The tradeoff is temporary redundancy and extra data-copying time, which is almost always cheaper than downtime. This applies to columns, constraints, indexes, and table replacements.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-30T04:51:51.051128+00:00— report_created — created