The query was fast. The data came back clean. But the table needed one thing — a new column.
Adding a new column sounds simple. In production systems, it is not. Schema changes touch live data. Mistakes can lock tables, block writes, or cascade through dependent services. The right approach combines precision with zero downtime.
Start with intent. Decide if the new column is nullable, if it gets a default value, or if it must be filled from existing data. Plan the migration in two phases: first, alter the schema; second, backfill. This split avoids long-running locks and keeps the database responsive.
For SQL databases, execute an ALTER TABLE to add the column. Use options that minimize locks. For PostgreSQL, adding a nullable column without a default is fast. Adding a default writes to every row, which can block. Use ADD COLUMN ... DEFAULT ... with NOT NULL only when the dataset is small or during a low-traffic window.