The query ran fine until the schema changed. Now you need a new column, and the clock is running.
Adding a new column should be simple. In practice, it touches storage, queries, indexes, and application logic. The wrong step can lock a table, stall production, or corrupt data. The right step makes the change invisibly, without downtime or regressions.
A new column starts in the database definition. First, define the column name, type, and nullability. Use explicit defaults when backfilling existing rows. Avoid implicit type conversions. Consider storage size for large datasets.
On production systems, run schema migrations in small, reversible steps. Create the column with a default value or allow NULL until backfill is done. For large tables, batch updates to avoid long-running locks.
If the column affects indexes, create them after the backfill. Building an index during peak traffic can degrade performance. Schedule index creation off-peak or use concurrent index options if your database supports them.