The table schema was final, or so we thought. Then a single requirement changed, and everything broke. The fix was clear: add a new column.
Adding a new column is simple in theory, but in production it can carry risk. Downtime, locked tables, and inconsistent data can follow if the process is not planned. For relational databases like PostgreSQL, MySQL, or MariaDB, a new column should be introduced with care. The choice of default value, nullability, and data type will shape performance and migration speed.
For PostgreSQL, ALTER TABLE ADD COLUMN is straightforward, but adding a non-null column with a default will rewrite the entire table, which can stall queries. Using a nullable column first, then backfilling in small batches, avoids long locks. In MySQL, online DDL with ALGORITHM=INPLACE can help, but watch for engine-specific limitations.