Liquibase and Database Versioning – Challenges & Solutions

In my previous blog, I discussed Hibernate and database integration challenges. In this blog, I shall share my experience with Liquibase and database versioning challenges.

Database versioning – the expected challenges

Delivering improvements to the database across different environments and into the production has often taken a lot of overhead. Especially when you have a growing team of developers. In contrast to my previous blog, which focused on the problems faced by the developers. In this article, let’s understand the challenges faced by Architectures and Project Managers and the popular solution used in today’s industry.

What are the challenges?

During the deployment, there is a higher chance to miss-out or execute unwanted database scripts, when the deployment fails. This unwanted rework breaks ongoing delivery cycles and at the same time increases pressure on the entire technical team to rectify the effects. Additionally, the other challenges are:

  • To track and version database changes along with their application code change versioning
  • To manually track database scripts executed along with related code-change deployment across various environment from development to QA and to the production
  • To continuously integrate, build and deploy processes

What is the Solution?

Although there are a variety of database versioning tools in the industry that relies on the manual creation of SQL or SQL-like changesets. Many use a simplified tracking system that does not scale to multiple developers or code branches. Similarly, some tools are not change aware.  Such solutions work well for projects where only one person adds changesets and/or there are no branches, but it quickly breaks down when the team and branch increases.

However, one known solution available in the industry is Liquibase. It is an open-source database-independent library for tracking, managing, and applying database schema changes. It allows us to write database scripts that can be versioned and shipped to different environments. It also helps to organize incremental database changes into different changesets and apply them to the database.

What does Liquibase offer?

  • Eliminates manual database scripts tracking, intelligently prevents multiple executions of the same script, and detects changes in already executed scripts.
  • Provides standard SQL notation with a variety of databases making developers’ lives easy while preventing from learning different database-specific DDL queries.

What does Liquibase not offer?

The current version of Liquibase does not support NoSQL, it currently supports RDBMS only.

Database using Liquibase – the unexpected

Liquibase maintains a list of database scripts executed in one of the database tables. When the application restarts it checks for new script file entries in master.xml file and executes those new scripts marking their entry into the database table to be tracked.


Your application works perfectly in your local machine may fail to start in QA or production environment. This could be due to the Liquibase change scripts unable to execute or due to failure in acquiring change lock.


This issue may cause in two scenarios:

  • The application frequently restarts because of abrupt crashes before Liquibase change scripts complete the execution.
  • The multiple instances of the same application started at the same time, then either of the application may encounter problems in acquiring a change lock.


Easy and quick fix would be to remove lock entry from DATABASECHANGELOGLOCK table.

As such, the following solution not only resolves the Liquibase lock issue permanently but also improves application booting time by eliminating Liquibase validating steps.

  • Enable Liquibase execution property in your application only when you want to execute new database scripts. Once executed, then disabled it again.
  • Execute Liquibase scripts from one application instance only by stopping other instances in a clustered environment.

Hope that the solutions enable to better plan and strategies database versioning model in complex environments. We will continue to share more of these experiences with our fellow Engineers!

Maulik Bamania | Lead Software Engineer

Maulik Bamania is a lead software engineer at GS Lab and has over 13 years of experience in enterprise application design and development. He is an avid technology reader and likes to learn about the latest technology trends to deliver quality solutions for customers. He has experience across all the facets of application management including, development, management, deployment, and application support.

Read more blogs by Maulik