How not to shoot yourself in the foot using Liquibase

Never been, and here again!


On the next project, we decided to use Liquibase from the very beginning to avoid problems in the future. As it turned out, not all young team members know how to use it correctly. I held an internal workshop, which I then decided to turn into an article.


The article includes useful tips and descriptions of the three most obvious traps that you can fall into when working with relational database migration tools, in particular Liquibase. Designed for Java developers at the Junior and Middle level, for more experienced developers it may be interesting to structure and repeat what is most likely already known.



Liquibase and Flyway are the main competing technologies for solving the problems of version control of relational structures in the Java world. The first is completely free, in practice it is most often chosen for use, and therefore Liquibase is chosen as the hero of the publication. However, some of the practices described may be universal, depending on the architecture of your application.


– . , . , , . , .


, :



, :




, , .


1. Liquibase


, , . , . , , . , Liquibase rollback . https://habr.com/ru/post/178665/ , rollback .


2. –


: Β« Persil β€” PersilΒ». Liquibase β€” , . β€” , β€” . DBA Architect Β« Β», , , SQL Developer.


3. ,


pull , , β€” , . - β€” . - β€” Liquibase. -. , . SQL XML , , , . , .


4. ,


, , . , . Liquibase , , , . , .


5. ,


privacy, , β€” , , 100% .


6.


, . , , , . - β€” . , . code review.


7. , !


, , . , , . .



, , , , , -?


1.



4, . , pull request, . :



  1. - , , , .
  2. - 5. Cherry Pick .
  3. .
    Liquibase 4, . 4 . .

, Liquibase, , . validCheckSum, 1.7 - , . https://www.liquibase.org/documentation/changeset.html :


Add a checksum that is considered valid for this changeSet, regardless of what is stored in the database. Used primarily when you need to change a changeSet and don't want errors thrown on databases on which it has already run (not a recommended procedure)

-, .


2. ,



, . , pull request . , , . .


, . , - . , , . , , Foreign Key, . , 100% .



  • , . , - , . , , , .
  • β€” . , , , . , - .
  • β€” environment , , .

, , , . , , , , -.


3. Liquibase


, Liquibase, .


, , , , .



:



4.


, , Liquibase , . :


  • .
  • , , .
    . , , .


, , Liquibase . , Liquibase jar , , .


CI/CD \ . Liquibase https://www.liquibase.org/documentation/command_line.html. , .



, . , , . , . , , , – .


All Articles