Adding a new column to a database sounds trivial. It is not. If done right, it is seamless. If done wrong, it can take down your application. A new column changes the shape of your data. It touches schemas, migrations, queries, indexes, and APIs. Every layer of your stack feels it.
Plan before you execute. First, decide if the new column is nullable or requires a default value. A nullable column can be deployed faster, but you risk inconsistent data. A non-null column with a default forces the database to write to every row, which can lock tables and slow production.
Roll out the schema change in stages.
- Add the new column as nullable.
- Backfill data in small batches to avoid locking.
- Update application code to handle the column.
- Add constraints or indexes after the data is ready.
Test the migration against realistic datasets. Use production-like volumes. Measure query plans before and after the change to catch performance regressions.