Adding a new column is one of the most common schema changes in software, yet also one of the most misunderstood. Done wrong, it leads to downtime, blocked writes, and long-running migrations. Done right, it’s invisible to the end user and gives your system new capabilities without risk.
A new column should start with a clear definition: its name, type, nullability, and default value. Avoid changing these decisions mid-flight. In relational databases like PostgreSQL or MySQL, adding a nullable column with no default is instantaneous on large tables. Adding a non-null column with a default often rewrites the entire table and locks it during the operation. For high-traffic systems, that’s a serious hazard.
The safe pattern is additive and iterative. First, add the new column as nullable with no default. Second, backfill the values in small, controlled batches to avoid load spikes. Third, enforce NOT NULL or add your default after the data is in place. Always track progress and confirm no writes are missed during the backfill.