The table was live, traffic pouring in, and the schema had to change. You needed a new column. Not tomorrow. Now.
Adding a new column sounds simple, but in production, speed and safety decide whether you keep the lights on. Schema changes can lock tables, stall writes, or even drop connections. The right approach depends on your database, migration strategy, and the scale of your data.
In PostgreSQL, adding a nullable column with no default is fast. PostgreSQL only updates system catalogs when you run:
ALTER TABLE users ADD COLUMN last_login TIMESTAMPTZ;
No table rewrite. Minimal impact. But set a default and you trigger a full rewrite—on large tables, this blocks until done. The better way is to add the column, backfill in small batches, and then set the default and NOT NULL constraint.
In MySQL, ALTER TABLE may lock the table by default. With InnoDB and ALGORITHM=INPLACE, simple adds can run online. However, adding a column in the middle of the table forces a full table rewrite. Place new columns at the end to avoid downtime.