The database waits. You run the query. But the schema is wrong, the data is half-shaped, and now you need a new column.
Adding a new column can be simple or dangerous. Done well, it unlocks new functionality without slowing production. Done poorly, it locks tables, blocks writes, and drags response times into the ground. The difference comes down to planning, tooling, and execution.
First, define the purpose of the new column. Know the type, defaults, and whether it must be nullable. Avoid nulls unless they serve a real use case. For enums, choose a type that can evolve without migrations. For text, know the limits before you set them.
Second, choose the migration strategy. On small datasets, a direct migration works. On large datasets, use a phased approach:
- Create the new column as nullable.
- Backfill data in batches.
- Add constraints or defaults once backfill completes.
Work in transactions only if the table size allows it. For large tables in production, avoid operations that block queries for long periods.