What is schema migration versioning and why is it important?
Answer
Schema migration versioning tracks database schema changes as ordered, versioned files (migration scripts) stored in version control alongside application code. Each migration has an up (apply change) and down (revert change) operation. A migrations table in the database records which migrations have been applied. This ensures: all environments (development, staging, production) have the same schema; team members can reproduce the schema from scratch; schema changes are reviewed in code review; and rollback is possible. Tools: Flyway, Liquibase (Java), Alembic (Python), Rails migrations, Golang-migrate. Without versioning, schemas between environments diverge and deployments break.
Previous
What is a self-join and when is it used?
Next
What is database sharding and what are its challenges?
More Database Design / Normalization Questions
View all →- Intermediate What are database anomalies and how does normalization prevent them?
- Intermediate What is denormalization and when is it used?
- Intermediate What are isolation levels in database transactions?
- Intermediate What are dirty reads, non-repeatable reads, and phantom reads?
- Intermediate What is query optimization and what is a query execution plan?