DB migration tools
Similarities between Liquibase and Flyway:
Are open-source to an extent and help manage, track and deploy database schema changes.
Use a versioned migration approach to a database schema change.
Are based on Java and provides extensive support for Java frameworks like Spring Boot and Vert.x.
Support integration with build tools like Maven and Gradle.
Can run independently from the command line through provided scripts.
Support a wide variety of databases.
Liquibase | Flyway | Aspect |
---|---|---|
SQL, XML, YAML, JSON DB-agnostic languages and apply schema changes to different DB types. | uses SQL for defining a change | Defining a change |
doesn't need to follow any of the file name conventions. Changes are managed by one ledger known as a master changelog which will be defined as including all the migrations | linear DB versioning system that increments on each versioned change. This can create conflicts with parallel development. The filename of script defines the type of migration. Convention of prefixes as V (for versioned), U (for undo), and R (for repeatable). It will be followed by a version number and a separator __(two underscores) followed by a description and a suffix .sql such as V01__Add_New_Column.sql. | |
stores its deployed migrations in a table named databasechangelog | stored in the database schema with a default table named flyway_schema_history. | storing a change |
uses a separate file named master_changelog in which the changes are deployed in the order they are defined | the order depends on the version number and migration type in the filename | execution order of change |
provides a way to roll back everything or undo specific migrations (available only on paid versions). | has a undo migration, which can be deployed with a file name that starts with U followed by the version that needs to be undone | rollback a change |
easily add labels and contexts to ensure deployment in certain places. | capable of doing it, but you would have to set up a different configuration file for each environment or database | selective deployment of a change (deploy a change to only one environment) |
migration within a Java file | migration within a Java file | java based migration |
allows users to take a snapshot of the current state of the DB. We can use this state to compare it to another database. This would be very helpful in scenarios like failover and database replication | doesn't support any of the snapshot features | Snapshots & Comparing Databases |
offers an added feature called pre-conditions. Preconditions allow users to apply changes based on the current state of the database. A changeset will only execute if it passes these preconditions. | doesn't support this. But through procedures, we can apply conditions in most SQL-based databases. | Conditional Deployment |
you can generate DB diff | not possible | Diff generation |
Strategy how to rename table column using Flyway migration and K8s
Last updated