Hi Guys! I am back with a new blog post titled “Power of Liquibase”. This post is meant for those who have a basic idea of using Liquibase. As we know that Liquibase is used to keep a track of the changes that we apply to the database. It not only keeps a snapshot of the database state but also provides various other features. Here is a standard migrator runner given on Liquibase Documentation Page:

java -jar liquibase.jar --driver=com.mysql.jdbc.Driver \
--classpath=mysql-connector-java-5.1.22.jar \
--changeLogFile=changeLogFile.xml \
--url="jdbc:mysql://localhost:3306/dbName" \
--username=username \
--password=password \

We need to provide the changLog file path,database connector jar file,driverName, db url, username and password before executing the script.

Some of the advanced features of liquibase are:

Contexts :  You can think of “Context” as a group name/category which is used to differentiate different changesets . Let’s say, you want to execute some changesets against your local database and some on your server database. So, in that case you can tag some changesets to run locally and some on the server’s database.


<changeSet id="SomeId" author="Author Name" context="prod">

The string “prod” is not pre-defined, you can choose any string you like. Now when you execute a changeset using the Standard command-line script you can specify a set of contexts(–contexts = prod,test) which will run changesets specified in the script and also those changeset which are not tagged using context tag.


Pre-conditions : It is just like an if condition used in programming language. You can associate a pre-condition with a changelog or changeset. The execution of a changeset would depend on the precondition specified. The changeset is executed if the precondition becomes true. If the precondition becomes false, then the current changeset is skipped and continues with next one, or the whole execution is halted depending on “onFail” tag.