Expand-contract migrations, also known as parallel-change migrations or zero-downtime migrations, are a two-phase approach to database schema changes that prioritize backward compatibility and minimize system downtime. This pattern is especially useful in continuously deployed systems, where database migrations need to be seamless and non-disruptive to maintain service quality.
The expand-contract migration process involves two main phases:
Expand Phase: In this phase, the database schema is expanded to accommodate the new schema changes. This often involves adding new columns, tables, or indices without removing or altering existing ones. The application code is then updated to use the new schema elements while still maintaining compatibility with the old schema.
Contract Phase: After the expand phase is complete and the application has successfully transitioned to using the new schema, the contract phase begins. This phase involves removing or altering the old schema elements that are no longer needed, effectively “contracting” the database schema to its final state.
This approach ensures that the database remains compatible with both the old and new application code during the migration process, allowing for smooth transitions without requiring system downtime or impacting end users. By prioritizing backward compatibility and minimizing disruption, expand-contract migrations have become a popular choice for organizations that require efficient and reliable database management.
- Release Management MOC
- Big-Bang Migrations
- Branch by Abstraction|branch by abstraction
These are possible follow-up zettels…
- Expand-Contract Migrations: Best Practices
- Expand-Contract Migrations: Common Pitfalls and How to Avoid Them
- Expand-Contract Migrations: Handling Data Transformations
- Expand-Contract Migrations vs. Lock-Step Migrations: A Comparison
- Strategies for Testing Expand-Contract Migrations
- Expand-Contract Migrations in Microservices Architectures
- Leveraging Feature Toggles in Expand-Contract Migrations
- Using Expand-Contract Migrations with Different Database Types (Relational, NoSQL)
- Expand-Contract Migrations: Rollback Strategies
- Tools and Libraries for Implementing Expand-Contract Migrations
- Zettel: Backward Compatibility in Expand-Contract Migrations
- Zettel: Minimized Downtime with Expand-Contract Migrations
- Zettel: Flexibility and Scalability of Expand-Contract Migrations
These note titles can help you explore various aspects of expand-contract migrations, such as best practices, testing strategies, comparisons with other migration approaches, and integration with different database types or architectural patterns.