The migration stalled. Everyone stared at the schema diff on the screen. The problem was simple: you needed a new column.
Adding a new column sounds trivial until it isn’t. In production systems with millions of rows, schema changes can lock tables, spike CPU, block writes, and cause downtime. The right approach depends on your database engine, the size of your data, and your need for zero downtime.
For PostgreSQL, a new column without a default or NOT NULL constraint is fast; it only updates the metadata. But adding a column with a default in older versions rewrites the entire table. Use ALTER TABLE ... ADD COLUMN and then UPDATE in batches if needed. In MySQL, ALTER TABLE operations can be blocking for large datasets unless you use ONLINE DDL (InnoDB) or specialized tools like gh-ost or pt-online-schema-change.
In distributed databases, adding a new column can trigger schema propagation events. Test in staging before running in production. Always monitor replication lag, vacuum processes, and query performance after the change.