The migration script fails halfway through. The schema is locked. You need a new column, and you need it now.
Adding a new column sounds simple. In practice, production databases turn it into a high-stakes operation. The wrong command can lock tables for minutes—or hours. Every second counts. This is where preparation and precision decide whether you ship or stall.
Start by defining the new column with data type, nullability, and default value. Avoid defaults that force a full table rewrite on large datasets. When possible, add the column as NULL first, backfill in batches, then apply constraints in a separate step. This reduces downtime and contention.
In Postgres, ALTER TABLE ... ADD COLUMN is usually fast if no default is set. For MySQL, watch out for storage engine differences. In both, test schema changes on replicas or staging environments with production-level data volumes. Measure the query plan changes after the column exists—indexes, statistics, and query caching may shift unexpectedly.