The query returned, slow and heavy. A table with millions of rows. A product release blocked by one thing: we needed a new column.
Adding a new column seems simple. In practice, it can lock writes, spike load, and block scaling. The wrong migration strategy can stall your app in production. The right one is seamless.
For relational databases like PostgreSQL and MySQL, ALTER TABLE ADD COLUMN is where many teams start. On small datasets it works. On large ones, it can be dangerous. Some engines need to rewrite the whole table. That means downtime. Even in engines that allow quick metadata-only changes, adding a column with a default value can still be expensive.
Safe schema changes require planning. One pattern: add the new column without a default, let it be null. Backfill in small batches with a background job. Then apply the NOT NULL constraint and default later. This reduces lock time and keeps the system responsive.