The schema changed overnight, and now the system needs a new column.
Adding a new column is one of the most common database operations, but it can destroy performance or break production if handled carelessly. The right approach depends on the database engine, the data volume, and whether zero downtime is required.
In PostgreSQL, ALTER TABLE ADD COLUMN is simple for small datasets, but on large tables it may lock writes. Adding a column with a default value that is not NULL can rewrite the entire table. To prevent long locks, add the column as nullable first, then backfill in controlled batches, and finally set the default and constraints.
In MySQL, adding a new column can trigger a table copy depending on the storage engine and version. For InnoDB with ALGORITHM=INPLACE or ALGORITHM=INSTANT, many schema changes are non-blocking. Always check SHOW VARIABLES LIKE 'innodb_online_alter_log_max_size' to avoid spillover that could slow the operation.