The query runs, but the result is wrong. The table is missing what matters most. You need a new column, and you need it now.
Adding a new column sounds simple. It can be simple—if you choose the right approach for your database, schema, and traffic load. Do it wrong, and you lock tables, drop queries, or stall deployments.
First, decide the column type. In relational databases like PostgreSQL or MySQL, adding a new column with a default value can trigger a full table rewrite. For large datasets, that means downtime. If you must set a default, consider applying it in a two-step migration:
- Add the new column as nullable and without defaults.
- Backfill values in batches.
- Add constraints or defaults afterward.
If you work with schema-less stores like MongoDB, a new column is just a new key, but you still need to handle old documents gracefully. Avoid assumptions in code. Use feature flags to phase in reads and writes to the new field.