The query ran in less than a second, but the result was wrong. A missing new column broke the feature.
Adding a new column sounds simple. It isn’t. If you ship production code, schema changes can be the sharpest edges in your stack. A new column can unlock functionality, store critical state, or improve query performance. But done poorly, it can corrupt data, stall deployments, and trigger downtime.
The first step is deciding the column name and type. Names should be explicit and permanent. Types must fit the data now and in the future. Avoid guessing. Decide on nullability. Enforce constraints if they protect integrity, but ensure they will not block rolling deploys.
Use database migrations to create the column. In systems with high traffic, run additive changes first. Write code that can handle both old and new schemas. Deploy migrations in phases: add the new column, backfill data in safe batches, then switch application logic to use it. Finally, remove any deprecated fields when the migration is complete and verified.