Liquibase with Maven and PostgreSQL

Programmers working on computer program
Reading Time: 3 minutes


Firstly the goal of this blog is to walk you through setting up a new Maven project on a Linux, Unix, or Mac computer with PostgreSQL. You will generate an example project in this tutorial. Then follow the instructions to put the concepts you learn about building new Liquibase projects in Maven into practice.

We will start this blog by installing and configuring Liquibase.

Step: 1 Install Liquibase

We advise starting with the Liquibase Installer if you are new to Liquibase. Since the installer comes with everything you need to get going right away, getting started is made simple.

Step 2: Configure Liquibase

You can use the command line to specify settings in Liquibase. Instead of having to set default values in the CLI unless you want to, you can save them in a file. A value supplied on the command line will always take precedence over a file when used with Liquibase.

If you are installing Liquibase from Liquibase Installer, the example files for both the XML and SQL formats are already included in your Liquibase download. Next, we advise that you continue reading about Using the Liquibase Installer.

Step 3: Set up your dashboard

Create a free Liquibase Hub account to view database release information for changes that occur in all environments in one location.

Although you’ll receive an API key after creating an account that you can use to link your changelogs to the dashboard. Once you’re connected, you can view in real time which changes are passing and failing in various scenarios.

Creating Liquibase project with Maven and PostgreSQL

Start by doing the subsequent actions to establish a Liquibase project in Maven that makes use of a PostgreSQL database:

  • Create a new project folder and name it MavenPostgreSQL.
  • dbchangelog.xml should be created as a new plain-text file in the MavenPostgeSQL directory. Your database structure modifications will be tracked in this file, which will serve as your changelog. On the Working with Changelogs page, you may get additional information about them. You will manually add one change in this tutorial.
  • Open the dbchangelog.xml file and update it with the following text. This is an empty changelog file.
<?xml version="1.0" encoding="UTF-8"?>  










  • Create another plain text file in the same directory and give it a name like
  • Add the following properties to the newly created Liquibase properties file:
changeLogFile: dbchangelog.xml

 url: jdbc:postgresql://localhost:5432/MYDATABASE

 username: postgres

 password: password
  • To the changelog, add a changeset. Insert a fresh changeset into the dbchangelog.xml file. The creation of the department table is one of the modifications in this changeset.
<?xml version="1.0" encoding="UTF-8"?>  









     <changeSet  id="1"  author="bob">  

         <createTable  tableName="department"> 
             <column  name="id"  type="int">  

                 <constraints  primaryKey="true"  nullable="false"/>  

             <column  name="name"  type="varchar(50)"> 
                 <constraints  nullable="false"/>  


             <column  name="active"  type="boolean"  




  • Create the Maven POM file for the project. Create a new plain-text file in the same directory named pom.xml.
  • Edit the pom.xml file and update it to have the following contents:
 <project  xmlns=""  

  • Go to the MavenPostgreSQL directory by opening the command prompt and selecting it.
  • Run the following command: mvn liquibase:update
  • Check your database updates under “MYDATABASE” via a database UI tool, such as “pgAdmin.” The database should now have a new “department” table.


In conclusion, in this blog, we covered the implementation of Liquibase with Maven and PostgreSQL.

References :

Liquibase documentation:

Knoldus blog :

Written by 

Hello! Currently, I am Software Consultant at Knoldus Inc. I have completed my B.Tech from Abdul Kalam Technical University. Right now I am focusing on JAVA Frameworks. Apart from that my hobbies are playing guitar and listening to music.