Use expand-and-contract. First add nullable columns, new tables, or indexes without changing existing behavior. Deploy code that reads both formats and writes compatibly, backfill in small resumable batches, verify counts/checksums, switch reads, then enforce constraints and remove old structures in a later release. Avoid one huge transaction and table-rewriting operations during peak traffic. Estimate locks and log growth, set timeouts, throttle batches, monitor blocking/replication, and have explicit pause/rollback criteria. For tenant data, every backfill and verification query must preserve RestaurantId and OutletId. Back up and rehearse on production-sized data; an application rollback cannot undo an incompatible schema change.
Backbencher Developer · · 0 likes