The query returns. The data is there, but the schema has changed. You need a new column, and you need it without breaking production.
Adding a new column is one of the most common database changes. Done well, it’s invisible to your users. Done poorly, it locks tables, causes downtime, or corrupts data. The key is precision.
First, choose the right migration strategy. In relational databases like PostgreSQL or MySQL, adding a new column with a default value can trigger a full table rewrite. For large tables, this is slow and blocks queries. Instead, add the column as nullable, then backfill in batches. Once data is populated, set the default and enforce constraints. This reduces lock time and keeps systems responsive.
In distributed systems, schema changes must be forward-compatible. Deploy application code that ignores the missing field, then roll out the migration, then deploy code that uses the new column. This sequence prevents null reference errors and ensures smooth rollouts across multiple services.