Adding a new column sounds simple. It is not. In production, data changes are dangerous. Schema drift, null defaults, inconsistent deployments—each one can break live systems. The cost of a bad migration is downtime, broken queries, corrupted data.
A new column changes not just the schema, but the code paths that read and write data. In SQL, ALTER TABLE ADD COLUMN is fast—until the table holds terabytes. Without caution, that single statement can lock writes, spike CPU, and block other sessions. On PostgreSQL, adding a column with a default requires a rewrite. On MySQL, it depends on the storage engine. In distributed databases, every node must receive the update in sync.
Best practice for adding a new column in production:
- Add the column without a default or constraint.
- Backfill data in small batches.
- Add constraints and defaults in a separate step.
- Deploy application code that uses the column only after the schema is ready.
Version your migrations. Test them in a staging environment with production-like load. Monitor replication lag. Keep rollback scripts ready. Do not trust “it ran fine locally.”