The migration stalled. All eyes were on the database. The task was simple on paper: add a new column without taking the system down. But the wrong move could lock a table, slow queries, or break production.
Adding a new column to a live database means balancing schema changes with uptime. A direct ALTER TABLE ADD COLUMN can cause downtime in some engines, especially on large tables. For PostgreSQL, adding a nullable column without a default is instant. Adding with a default rewrites the table. MySQL’s behavior varies by version; online DDL options can be fast, but require proper configuration.
Best practice is to create the column without defaults, backfill the data in controlled batches, and then set constraints or defaults in a separate step. This avoids long locks and replication lag. Always measure index build time before adding constraints that require full table scans.