The database paused, waiting for a decision. You needed a new column. Not later. Now.
Adding a new column in a production database is a common task, but the wrong approach can stall deployments, lock tables, and even cause downtime. The safest way to add a column depends on the database engine, the size of your dataset, and the requirements for default values and constraints.
In PostgreSQL, adding a new column without a default value is fast. It only updates the table’s metadata. But adding a column with a non-null default to a large table rewrites the entire table on disk, blocking other operations. For MySQL, an ALTER TABLE to add a column is almost always a blocking operation unless the engine version supports instant DDL changes.
When possible, add the new column as nullable first, then backfill data in small batches. This avoids locking and keeps application performance stable. After backfilling, you can add constraints like NOT NULL in a separate operation.