The query ran fast, but the data was wrong. You checked the schema again. The answer was obvious: you needed a new column.
Adding a new column should be simple, but in production systems the truth is different. Every migration carries risk. Downtime, locks, broken deployments — they all wait for the unprepared. An unplanned new column can stall releases, block features, and corrupt data if done wrong.
First, define the new column with clarity. Choose the correct data type. Set defaults where necessary. Avoid nulls unless the model demands them. Lock in constraints at creation if the data must be validated from day one.
Next, plan the migration path. On high-load databases, add the new column in a way that avoids full-table locks. Many relational systems allow adding nullable columns instantly, but defaults applied in the same step can cause table rewrites. Split the migration to add first, then backfill, then enforce constraints.