The database migration is live, and the schema just changed. You need the new field in production without breaking queries, slowing performance, or locking rows longer than necessary.
A new column seems simple, but the details matter. Column type, default values, nullability, and indexing all influence stability and speed. In high-traffic environments, adding a new column to a large table is a high-risk event. Poor execution can block writes, halt services, and trigger expensive rollbacks.
Plan the migration. Choose an approach:
- Online schema change tools like
gh-ostorpt-online-schema-changefor MySQL. - Partition-safe migrations in PostgreSQL using
ALTER TABLEwith careful lock management. - Incremental rollouts of new columns behind feature flags.
Set defaults intentionally. If you must backfill data, run it in controlled batches to avoid I/O spikes. Test for query compatibility so your ORM and raw SQL both recognize the changed schema. For large datasets, use nullable columns first, then populate them gradually.