How would you approach data model versioning in a continuously evolving application?
Instruction: Describe strategies for managing changes to a data model in an application that undergoes frequent updates and feature additions.
Updated
Official answer
Version schema changes as reviewed migrations alongside the application. Record applied versions/checksums, dependencies and ownership, but do not assume a version table alone makes upgrades safe.
Use an expand-and-contract approach for incompatible changes. Add a compatible field or structure, deploy code that works during the overlap, backfill existing rows in bounded restartable batches, validate, switch consumers, and remove the old structure only after older clients/jobs can no longer use it. Define how concurrent writes stay consistent during backfill; a one-time copy can otherwise miss later updates.
For a renamed or retyped field, test old and new application versions against the transitional schema. Validate counts, conversions, constraints, lock duration and workload impact on representative data. Feature flags can control application use but do not remove the locking or storage cost of executing a migration.
Plan rollback honestly. Dropping a column or converting data lossily may be irreversible without recovery, and restoring a backup can discard newer writes. Prefer a tested forward repair where appropriate and define recovery boundaries before deployment. Document model semantics as well as DDL so metric or meaning changes receive the same scrutiny as structural changes.