Two types of deployment approaches
State-based
(Declarative) deployment
Migration-based
(Imperative) deployment
Both approaches, at their root, are about the source of truth: the definition of how you want the database to look at the end or the scripts you produce to handle database change.
State-based Database Deployment
In a state-based database deployment, the ideal state of the database is defined and a tool is used to compare that ideal state against the current actual state of the database. Some tools, like Liquibase, can analyze the difference between the two and generates all the scripts to change the database.
Migration-based Database Deployment
In a migration-based database deployment, specific migrations for altering the state of a database are described by the user. It’s all about capturing individual change scripts during development. This approach helps teams more closely align with Agile and DevOps best practices:
- Small, incremental changes
- Use the same process for all code delivery
- Enables fast feedback loops
- Granular control of features
- Enables better testing
- Eliminates drift
Can both approaches be used?
Yes! While Liquibase does include comparative diff capabilities, Liquibase is primarily a migration-based tool. The diff capabilities are mostly intended to assist with onboarding new projects or ensuring that your database migrations are applied correctly.