The query ran, the migration failed, and the release clock was ticking. You needed a new column. The database didn’t care about your deadline, only about the rules you gave it.
Adding a new column sounds simple. It often is. But in production, on high-traffic systems, the wrong change can lock tables, block writes, and spike latency. The safe way to add a column depends on your database engine, schema size, and uptime requirements.
In PostgreSQL, ALTER TABLE ADD COLUMN is transactional and fast for small tables—but on massive ones, it can still block writes. Use ADD COLUMN ... DEFAULT with care. A constant default forces a table rewrite. For zero-downtime, first add the column with NULL, then backfill in controlled batches, then set the default.
In MySQL, especially before 8.0, adding a column can require a full table rebuild. Online DDL options like ALGORITHM=INPLACE or LOCK=NONE can help, but behavior varies by storage engine. Always test against production-sized data to see the real cost.