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.


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



Sample liquibase xml file:

<?xml version="1.0" encoding="UTF-8"?>


  <changeSet author='Vivek S' id="#99999- Contracts">

        <createTable tableName="contract">
            <column name="id" type="java.sql.Types.INTEGER">
                <constraints nullable="false" primaryKey="true" primaryKeyName="contract_pkey"/>
            <column name="entity_id" type="java.sql.Types.INTEGER">
                <constraints nullable="false"/>

            <column name="active_since" type="java.sql.Types.DATE" />
            <column name="notes" type="java.sql.Types.VARCHAR(200)"/>
            <column name="active" type="java.sql.Types.INTEGER">
                <constraints nullable="false"/>
            <column name="deleted" type="java.sql.Types.INTEGER">
                <constraints nullable="false"/>
            <column name="template" type="java.sql.Types.INTEGER">
                <constraints nullable="false"/>
            <column name="automatic" type="java.sql.Types.INTEGER">
                <constraints nullable="false"/>
            <column name="automatic_frequency" type="java.sql.Types.INTEGER"/>
            <column name="optlock" type="java.sql.Types.INTEGER">
                <constraints nullable="false"/>

<addForeignKeyConstraint constraintName="contract_entity_id_fk" referencedTableName="entity" referencedColumnNames="id" baseTableName="discount" baseColumnNames="entity_id"/>



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

liquibase --driver=com.mysql.jdbc.Driver 

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:

         <dbms type="oracle" />
         <dbms type="mysql" />

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. 🙂