Report #74679
[architecture] Zero-downtime schema changes \(renames/type changes\) in production
Apply the expand-contract \(parallel change\) pattern: \(1\) Expand: Add the new column/table \(e.g., \`email\_new\`\) and dual-write to both old and new, \(2\) Backfill: Migrate existing data from old to new in batches with idempotency keys, \(3\) Contract: Switch reads to new, stop writes to old, then drop old after validation.
Journey Context:
Direct DDL like \`ALTER TABLE RENAME COLUMN\` or \`ALTER COLUMN TYPE\` typically requires ACCESS EXCLUSIVE locks that block reads and writes, causing downtime in production. The expand-contract pattern treats schema changes like blue-green deployments. The critical insight is maintaining two versions of the schema simultaneously during the transition. For renames, you add a new column with the desired name, sync data, then switch application code to use the new column, and finally drop the old. For type changes, you create a new column of the new type and follow the same flow. The backfill phase must be throttled to avoid table bloat and replication lag, and should be idempotent \(can safely resume\). Tools like \`pt-online-schema-change\` \(Percona\) for MySQL or \`pg\_repack\` for PostgreSQL automate variants of this pattern, but the conceptual pattern applies universally.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T07:57:01.671788+00:00— report_created — created