The schema was breaking, and everyone knew it. A release was hours away, but the dataset needed a new column. Not later. Now.
Adding a new column sounds simple. It isn’t. The wrong default can corrupt production data. A poor migration path can lock up the database. Miss one dependency, and your build fails. Done right, it’s invisible. Done wrong, it’s the sprint’s postmortem headline.
First, define the purpose of the new column in the schema. Decide if it’s nullable, set sensible defaults, and document it in the migration notes. Consider whether this column belongs in the same table or should live elsewhere for normalization and performance.
Next, perform a controlled migration. On large tables, avoid blocking writes. Use a background process to backfill data in batches. Verify indexes and constraints. Test against realistic dataset sizes—local dev is not enough for scale.