The migration finished, but the data looked wrong. A missing new column in production had broken the reporting jobs. The fix was small: add the column, backfill, redeploy. Yet the downtime risk was huge.
Adding a new column in a database is one of the most common schema changes. Done poorly, it can lock tables, block writes, and trigger cascading failures. Done well, it happens online, with zero service interruption. The difference is in how the change is planned and executed.
Start by defining the new column with a default value of NULL and no constraints. This ensures the ALTER TABLE runs fast, even on large datasets. For PostgreSQL, avoid adding NOT NULL or default expressions inline—they require a full table rewrite. In MySQL, a similar risk exists depending on the storage engine and version.
After deployment, run a background migration to backfill the new column. This can be done in batches to control load. Once populated, apply constraints and defaults in a separate migration. This staged approach keeps migrations fast and safe.