In previous post, we discussed about the problem of Database deployment and use Liquibase for Database CI/CD purposes. We also discussed the basics of how liquibase works behind the scenes. Now the next step is to install and configure liquibase. The steps here are for Windows OS but Liquibase being a cross-platform tool, the same can be repeated on any major Operating System.
Since Liquibase itself is written in Java, we would need to have java installed on the machine where we need to run Liquibase. For this, we can either download Java from package repositories inside various Linux distributions and use package managers like yum/rpm in Red hat based distributions and apt/dpkg in debian based distributions. For Windows OS, we can use chocolatey or direct download it from Oracle and run it.
Note that we only Java Run time environment i.e. JRE and not Java Development Environment (JDK). Howver, if JDK is installed, then it should cover JRE as well. Also, since we are going to use the latest version of liquibase, we need to have Java 1.8 or plus. Once Java is installed, we can check for the proper version installed using
java -version command.
For this, we can go to Liquibase site and download the version appropriate for our Operating System. You would see two versions available for download:
Of the above versions, the .zip file is for Windows OS and .tar.gz is for Linux Distributions. Download the file and extract the zip contents to a directory, say C:\Liquibase. Now open environmental variables window and add the path of the extract directory to system variable PATH:
You can also use appropriate commands in PowerShell or bash for same. To verify, it is done properly, open a cmd/terminal window and run:
You should see an output like below:
Download JDBC Drivers
Liquibase needs database specific JDBC drivers to connect and execute commands on the database in reference. These drivers can be downloaded from Database Vendor site directly. The list of supported databases can be found here.
Download Liquibase using Ansible
We can also setup Liquibase using Ansible. Here’s a quick playbook for setting up liquibase on target group dbservers:
You’ll need to have ansible configured and setup in your environment. We can pass the liquibase_version value at run time using ––extra–vars. Below is one of the sample runs of above playbook:
In the next blog post, we’ll discuss how we can leverage Liquibase for Microsoft SQL server deployments.