A new column in a production database can trigger downtime, lock tables, or cause unwanted replication lag. Choosing the right approach depends on database engine, table size, and workload. In MySQL, ALTER TABLE can cause a full table copy unless you use ALGORITHM=INPLACE or ONLINE. In PostgreSQL, adding a nullable column with a default value can rewrite the entire table unless done in two steps: first add the column without default, then update in batches.
Plan migrations as part of your deployment pipeline. Verify that the new column definition matches constraints, indexing strategy, and application expectations. Ensure applications are column-aware before the migration runs to prevent null reference errors. Roll out in small, testable steps:
- Release application code that can handle the column existing or not.
- Deploy schema change.
- Backfill data in controlled batches.
- Enforce constraints or defaults after data is stable.
For high-traffic systems, use tools like pt-online-schema-change or pg_repack to apply new column changes without blocking queries. Monitor replication closely if running in a multi-region setup to avoid drift. Always benchmark the migration in a staging environment with production-scale data.