Adding a new column sounds simple. In practice, it’s a change that can ripple through schemas, indexes, queries, and background jobs. Done wrong, it locks tables, drops performance, or corrupts data.
The first rule: never deploy a new column directly on a live table without knowing the cost. Modern relational databases like PostgreSQL and MySQL handle column adds differently. Some can add a nullable column instantly. Others require a full table rewrite if defaults or constraints are set. Large datasets make this rewrite a serious operational hazard.
The correct sequence is deliberate. Add the new column as nullable first. Backfill it in small batches to avoid load spikes. Monitor query plans and replication lag. Once the data is in place, add constraints and indexes in separate steps. Deploy application code that uses the new column only after these migrations are complete and verified.