The query ran in seconds, but the numbers didn’t add up. A missing field. A gap in the table. You need a new column.
Adding a new column sounds simple. It’s not. In production, it can block, lock, or break your system if done wrong. The schema migration must be precise. Every step matters.
First, decide the type. Use integers when counting. Use text when storing strings. Avoid generic types that hide constraints. If you know it should never be null, set NOT NULL from the start. Default values matter; they can save you time and prevent gaps.
Plan your deployment. On large datasets, adding a column can cause downtime if you block writes. Use online schema changes when supported. Tools like ALTER TABLE ... ADD COLUMN in PostgreSQL or MySQL behave differently under load. Test on a copy. Measure the execution.