02.Database Migration - Flyway Vs Liquibase

Flyway Vs Liquibase




GitHub Link For Sample Project:

https://github.com/LahiruPriyankara/Liquibase

https://github.com/LahiruPriyankara/flyway


Differences between Liquibase and Flyway.

Flyway - Use SQL for defining changes.

Liquibase - Use SQL, XML, JSON, YMAL for defining changes (With Liquibase we can work with database-agnostic languages and easily apply schema changes to different database types).

 ----------------------------------------------------------------------------------------------------------------------------

Flyway - Follow file name conventions (a migration should have a 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).

Liquibase - changes are managed by one ledger known as a master changelog  (db.changelog-master) which will be defined as including all the migrations.

 ----------------------------------------------------------------------------------------------------------------------------

Flyway - Store changes in flyway_schema_history table.

Liquibase - Store changes in databasechangelog table.

 ----------------------------------------------------------------------------------------------------------------------------

Flyway - Execution order depends on the version number and migration type in the filename.

Liquibase - Execution order depends on separate file named master_changelog in which the changes are deployed in the order they are defined.

 ----------------------------------------------------------------------------------------------------------------------------

Flyway - Flyway also 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. Its paid version also offers even more complex undo functionality.

Liquibase -Liquibase provides a way to roll back everything or undo specific migrations.

Both the tools offer a decent rollback functionality, but considering only the free version, Flyway offers a good-to-use solution.

 ----------------------------------------------------------------------------------------------------------------------------

Selective Deployment of a change

Database changes environment wise deploy කරන්න වන time තියනවා.Example එකක් ලෙස local එකේ table එක update වෙන්න ඕනේ නමුත් dev එකේ ඕනේ වෙන්නේ නෑ වගේ එකක්.මෙය flyway and liquibase දෙකම use කරලාකරගන්න පුලුවන් වුනත් liquibase වලදී එය වඩා පහසුවෙන් කරගන්න පුලුවන් (Flyway is also capable of doing it, but you would have to set up a different configuration file for each environment or database)

 

In the liquibase

<changeSet id="id" author="lahiru" context="dev"></changeSet>

 In the application.property file

spring.profiles.active=dev

 

In flyway we can achieved it as bellow way.

In the application.property file

spring.flyway.locations=classpath:db/migration/common,classpath:db/migration/${spring.profiles.active}

 File structure



----------------------------------------------------------------------------------------------------------------------------

Conditional Deployment

Flyway - Flyway on the other hand doesn't support this.

Liquibase -Preconditions allow users to apply changes based on the current state of the database. A changeset will only execute if it passes these preconditions.

----------------------------------------------------------------------------------------------------------------------------

Snapshots and comparing Database

Flyway – Doses not allow.

Liquibase - Libuibase allows users to take a snapshot of the current state of the Database.

Snapshot is read only static view of source database as I exist at snapshot creation (Snapshot යනු existing database එකේ read only ලෙස තියන copy එකක් වේ).




----------------------------------------------------------------------------------------------------------------------------

Comments

Popular posts from this blog

02. Spring – Creating spring project clone it with GIT step by step.

02.What is MicroService?

06.Mongo DB - Query part 2 (Aggregation)