Adding a new column should be simple. In practice, it can crash queries, lock tables, or cause deploy delays. The bigger the dataset, the more dangerous the schema change. Zero-downtime migrations are not optional at scale.
A new column in SQL often means an ALTER TABLE statement. For small tables, this is fine. For large datasets, naive alters block reads and writes. On MySQL and PostgreSQL, adding a nullable column without a default is safer because it can be metadata-only. But adding a column with a default value forces a rewrite and can freeze the table.
To deploy a new column with minimal risk:
- Create the column as nullable with no default.
- Backfill data in small batches.
- Add constraints and defaults only after the backfill completes.
- Deploy application changes after the schema is ready.
For MySQL, tools like pt-online-schema-change or gh-ost allow live migrations. For PostgreSQL, use ADD COLUMN with care and batch updates using UPDATE ... WHERE with limits. Monitor replication lag during the process. Always test the migration on a staging database with production-like scale.