Database migrations can conflict even when source code merges cleanly. Teams need a shared approach to ordering, naming, compatibility, and deployment.
Make migrations additive where possible
Prefer adding nullable columns, new tables, or compatible indexes before application code depends on them. Deploy code that can work with both old and new schema versions, backfill data, and only later remove obsolete structures.
This expand-and-contract pattern reduces downtime and makes rollback more realistic.
Coordinate migration ownership
Use unique migration identifiers and review schema changes together. Two branches may independently add migrations that assume different prior states. Rebase and integration testing should catch ordering problems before release.
Consider production execution
Large table changes may lock or rewrite data depending on database engine and operation. Test migration duration and locking behavior against representative data. Separate long-running backfills from short schema changes.
Checklist
- Prefer backward-compatible schema evolution.
- Coordinate migration identifiers and ordering.
- Test lock and runtime impact on realistic data.
- Separate backfills from schema deployment.
- Remove old columns only after all consumers migrate.