Zero-downtime database migrations: how to change production schemas safely
A zero-downtime schema change is not about finding one magic ALTER TABLE command. It is a process of preserving compatibility between old and new application versions, controlling locks and operation cost, migrating existing data, and delaying destructive changes until old code is no longer serving traffic. In practice, the safest approach is to split the change into several phases, commonly described as expand, migrate, switch and contract.