The deployment froze, and the database waited. You needed a new column, but downtime was not an option.
Adding a new column is one of the most common schema changes in software. It should be simple. Yet in production systems with live traffic, even small changes can cause locks, block queries, or trigger a cascade of failures if handled poorly. Precision matters.
A new column in SQL alters the table definition and updates the metadata in the system catalog. Depending on the database engine, this can be instant or expensive. In PostgreSQL, adding a nullable column with a default that is not a constant can rewrite the entire table. MySQL can often add a column without a full table rebuild, but certain types or default expressions will force one. These details decide whether your migration is fast or dangerous.
Plan the migration. Decide the column type, nullability, and default carefully. For large datasets, avoid setting a costly default in the ALTER TABLE statement. Instead, add the column as nullable, backfill in small batches, then apply a SET DEFAULT later. This pattern prevents long locks and keeps queries responsive.