The query ran fast, but the schema was wrong. You needed a new column.
Adding a new column in a production database is simple to describe but dangerous to execute. The steps, the risks, and the performance constraints matter as much as the final schema change. Schema migrations are code, and code needs discipline.
A new column changes storage layout, query plans, and possibly indexes. On large tables, an ALTER TABLE ... ADD COLUMN can lock writes, spike CPU, and stall replicas. Choosing the right migration strategy is the difference between an instant deploy and hours of downtime.
Start by reviewing the data type. Avoid defaults that force a full table rewrite unless needed. If the column is nullable, define it without a default value to reduce locking time. Some databases, like PostgreSQL, can add a nullable column instantly. Others may scan. Check your query plans before and after.
For columns with a default, consider a two-step migration. First, add the new column as nullable without a default. Then backfill data in controlled batches. Finally, alter the column to set the default and apply constraints. This pattern keeps transactions small and prevents long locks.