Adding a new column is one of the most common database changes. Done right, it is seamless. Done wrong, it locks tables, stalls writes, and takes down production. The steps are simple, but the execution needs precision.
First, decide if the new column is nullable or requires a default value. Nullable columns can often be added instantly. Non-null columns with defaults can lock the table on large datasets. To avoid downtime, add the column as nullable, backfill data in batches, then enforce constraints.
Second, check for replication lag. Adding a column on a primary can propagate schema changes to replicas. Monitor replication closely during the migration to avoid breaking failover.
Third, update application code in two phases. Deploy code that can handle the column before it exists. Then add the column. Finally, deploy code that depends on it. This makes the migration safe and reversible.