The schema migration finished, but the data didn’t fit. You needed a new column, and you needed it without downtime.
Adding a new column to a production database sounds simple. In reality, it’s a high-risk operation. The size of the table, the database engine, and the default values you set can all turn into bottlenecks. One blocking transaction can cause slow queries, lock contention, and missed SLAs.
In PostgreSQL, ALTER TABLE ADD COLUMN is fast if no default is applied. The database simply updates the metadata. But adding a column with a non-null default forces a table rewrite. That can lock reads and writes until the operation finishes. To avoid this, create the column as nullable first, then backfill in batches, then set constraints.
MySQL behaves differently. Adding a column often triggers a table copy unless you are on InnoDB with ALGORITHM=INPLACE or INSTANT (available in newer versions). Always check execution plans with EXPLAIN ALTER TABLE where supported. On massive datasets, pause and stage changes to avoid replication lag or inconsistent replicas.