当前位置:网站首页>Database migration tool flyway vs liquibase (II)

Database migration tool flyway vs liquibase (II)

2022-06-24 11:34:00 Qing Cheng sequent stone

Keep creating , Accelerate growth ! This is my participation 「 Nuggets day new plan · 6 Yuegengwen challenge 」 Of the 29 God , Click to see the event details

Personal home page :@ green Cheng Foreman stone

I believe there is no need to describe why the use of database migration tools is critical to modern applications that use relational database engines . I just want to say , They can make our life easier , And help us automate complex and repetitive processes . Through this article , I will review the two most common open source migration tools ,Flyway and Liquibase The similarities and differences between them provide some further insights .

Flyway and Liquibase The similarities of

Both are open source to some extent , Some functions are provided for free , But there are also paid versions , More features . And both can use ordinary old SQL To write migration scripts .

Both have strong "Java guide ", Also built-in right Maven or Gradle And other basic building tools , And with the most common Java Integration of framework , for example Spring Boot.

Both can be used as simple shell The list of supported databases that the script runs from the command line is more or less similar . There may be some minor differences in supported versions or drivers , But on the whole , There is no obvious difference between them in this field .

Both are based on the same approach to dealing with database changes , That is, database delivery based on migration . Both tools attempt to implement Martin Fowler Propose and explain the concept of evolutionary database Evolutionary Database Design.

Flyway and Liquibase The difference between

Use across databases

Both of these tools allow you to use pure SQL Write migration scripts in , So as long as you use it , When migrating between different database engines , You have to customize your script . However , You will probably use " magic " Or queries with keywords that exist in a particular engine , This can greatly increase your database performance . If you decide to use Liquibase And write your scripts in other supported formats , You should easily use the same script in different databases .

Variance generation

You can use it. Liquibase Generate diff, but Flyway You can't , Even the paid version . This is also our choice in the project Liquibase instead of Flyway One of the main reasons .

Integrate

As I mentioned in the paragraph describing the similarities , The two tools are almost the same in this respect . There is a very important difference , I want to mention .Flyway There's a local one Java API. It is designed to help us with more complex migrations , such as BLOB and CLOB Or advanced batch data changes . This API It is very useful in some cases , This may be our choice Flyway instead of Liquibase Why .

Roll back

It's time to describe how our tool handles rollback . One side , stay Liquibase In the change log file of , They are relatively easy to set up . in fact , stay changelog Of XML In structure , There is even a special field defined as rollback code . On the other hand , stay Flyway in , It is only available in the paid version . Unfortunately , I have no chance to use it , So I can't make a comprehensive comparison here . If you are willing to pay for your tools , that Flyway This function of is worth trying . However ,Liquibase The paid version of is said to have more sophisticated support for different kinds of rollback , So it's worth checking .

Change order management

The last thing I want to mention and compare is the order in which changes are managed . ad locum , Both tools have a completely different approach .Flyway It is based on the concept of linear database version management . It means , The order in which changes are applied depends on the name of the migration script . in fact ,Flyway The migration script for has a complete naming rule , If you want it to work as expected , You must follow this rule . stay Liquibase in , The order in which changes are applied to our database instance is based on a specific change location in the entire change log file . You can be sure of , If you put your changes in a certain order in the change log , Your changes will be applied to your database in exactly the same order .

image.png

summary

I described it Liquibase and Flyway Some similarities and differences between , Try to be impartial and objective . This article should give you a better understanding of how these two tools work and the possibilities they offer . As for the final choice , It is you who make the decision according to the complexity of the data and the system requirements .

If you are not satisfied with both , There are other alternatives , Please refer to the figure below .

image.png


juvenile , I didn't see enough. ? Click on the stone Details , Just a little , There might be a surprise ? Welcome to support give the thumbs-up / Focus on / Comment on , Your support is my biggest motivation , Thank you very much !

原网站

版权声明
本文为[Qing Cheng sequent stone]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/175/202206241022085580.html