Adding a new column can be trivial or destructive, depending on scale, locking behavior, and migration strategy. It’s a small change in text but a large change in execution. At millions of rows, the wrong approach can grind production to dust.
A safe new column migration starts with understanding your database engine’s ALTER TABLE mechanics. In PostgreSQL, adding a nullable column without a default is fast; adding one with a default rewrites the table and blocks writes. In MySQL, online DDL options and ALGORITHM=INPLACE can help avoid downtime. On systems like SQL Server, default values often trigger a full table rewrite unless managed carefully.
Plan defaults in application code, not schema changes, when uptime matters. Use multiple deploy steps:
- Add the column as nullable with no default.
- Backfill values in controlled batches.
- Update the column to set a default in a later migration if needed.
This method prevents long locks and keeps latency stable.