Smoke curled from the build server. The migration had gone wrong. You open the schema and see it: you forgot the new column.
Adding a new column sounds simple. It is not. In production, it touches live data, active queries, and running code. A careless change risks downtime, data loss, or broken features. This is why the process must be deliberate, precise, and tested.
Plan the new column. Start with exact requirements—data type, constraints, default values. Avoid NULLs unless unavoidable; they complicate logic and indexes. Decide how existing rows will populate the new column, whether via default values or a backfill script.
Update the schema safely. In SQL databases, use migrations. Break the change into steps when possible:
- Add the column without constraints.
- Backfill data in controlled batches to avoid locking.
- Add constraints and indexes after the data loads.
For NoSQL stores, define the new field in code and handle missing values in the application until writes populate it consistently.