Liquibase is an open source technology for tracking, managing and applying database schema changes.

All changes to the database are stored in XML files in the form of change-sets and is identified by a combination of an “id” and “author” tag. All the change-sets are applied sequentially one by one.It also creates DatabaseChangeLog Table and DatabaseChangeLogLock table when you first execute a changeLog File.

DatabaseChangeLogLock table maintains the lock information granted to the particular user. The purpose of this table is to make sure that two machines doesn’t try to modify the data simultaneously.

Screenshot:

DatabaseChangeLog table contains the list of the statements executed on the database.

Screenshot:

Sample liquibase xml file:

To execute the liquibase script from command line use this:-

The main question is why to use liquibase ?

The main reason is that it keeps a track of all changes applied to a database. We can also rollback to a particular change. It also enables use to specify pre-conditions like which change-set should be executed on which db type like this:

Following are the advantages:

  • Executable via command line.
  • Support for more than 5 database systems
  • DBMS Check, user check using preconditions

That was all about liquibase! I hope you liked it. 🙂