The fix was simple: add a new column. Simple, except nothing in production is ever simple.
A new column changes the structure of your data and the contract your application relies on. Whether you’re using PostgreSQL, MySQL, or a cloud-native managed database, this single operation can break queries, slow reads, or stall writes. For systems with billions of rows, an ALTER TABLE ADD COLUMN can lock tables and block traffic if done without care.
Before adding a new column, define its exact purpose. Name it with precision. Decide if it allows nulls. Set correct defaults. Specify constraints early to avoid silent corruption. Run the change in a staging or shadow database to measure migration time and impact.
In PostgreSQL, adding a nullable column without a default is nearly instant. But adding a column with a non-null default rewrites the entire table. That’s downtime in disguise. Mitigate it by adding a nullable column first, backfilling in batches, then enforcing non-null later.