What is Liquibase?
Liquibase is an open source database change management tool built on Java.
What is its need?
Performing database migrations is an essential task in almost every software project. During the life cycle of an application, the development team may produce thousands of database changes.
How does it help?
Rather than writing SQL queries directly against the database to create, update or drop database objects, developers define their desired database changes in XML files.
These XML files are called as “changelog”. They contain a list of “changesets” that are used to define a desired database change in a database.
In order to start using Liquibase in your projects, add the below Maven dependency into your pom.xml:
You can also check if a newer version of liquibase-core is available here.
You can also download the ZIP version of Liquibase from it’s official website http://www.liquibase.org/download/index.html
How does it work?
When Liquibase is executed, you must specify the database against which to apply your changesets.
Liquibase uses two tables to manage changes to the database:
If the tables don’t exist on the target database, they are created.
1. Databasechangelog table:
The databasechangelog table contains a listing of every changeset that has been applied to this database. The databasechangelog table contains a list of all the statements that have been run against the database.
2. Databasechangelock table:
An entry is added to the databasechangelock table which ensures only one instance of Liquibase is running at a time. The databasechangeloglock table is used to make sure two machines don’t attempt to modify the database at the same time.Liquibase then checks the difference of the entire table contents with the XML files and determines which changes still need to be applied. Once this is determined, Liquibase will then apply the changes to the database automatically.
More information can be found out from the below links: