The data was solid, but the schema could not keep pace. You needed a new column, and you needed it now.
Adding a new column is simple in theory, but the wrong approach can lock rows, inflate downtime, or trigger cascading failures. Whether you run PostgreSQL, MySQL, or a cloud-scale distributed database, the steps are similar but the impact varies.
First, define the column’s purpose with precision. Every new column changes queries, indexes, and storage. Decide the type, default value, and nullability. Avoid defaults that force a full table rewrite unless absolutely necessary.
In PostgreSQL, ALTER TABLE ... ADD COLUMN is straightforward, but large tables may require caution. Adding a nullable column is instant. Adding a column with a default value before version 11 rewrites the whole table. In MySQL, ALTER TABLE often rebuilds the table, so consider using ONLINE DDL if your storage engine supports it.