New Liquibase Package Manager Utility
Any time you install Liquibase, you also need to install the JDBC driver for your database. If you’re new to Liquibase (or you need to install it on a new system), this can be annoying and sometimes even daunting (especially if you don’t want to dig into “classpaths”).
Save a bit of time and effort by using the new open source Liquibase Package Manager (lpm). lpm is a utility that simplifies the Liquibase installation process by fetching and installing any JDBC drivers and extensions you need. You’ll never see the “Unexpected error running Liquibase: Cannot find database driver” again.
Developers are always looking to make their process easier, so we took inspiration from other tools that solved this problem, including Maven,
apt-get update, YUM, and npm. These applications have all helped inspire our team to build and release Liquibase Package Manager (lpm) as an open source experiment.
What is Liquibase Package Manager (lpm)?
lpm is a command-line utility that installs any required JDBC drivers and Liquibase extensions on your machine. (It has ALL the drivers for the databases Liquibase supports!) You can use it to easily search for, install, and uninstall Liquibase drivers, extensions, and utilities at a global or project level. Because lpm is a command-line utility, you can use it to install JDBC drivers and Liquibase extensions in whatever automation you currently use to install Liquibase.
We drink our own champagne 🥂
The first use of lpm (outside of the development and support team at Liquibase) was in our Docker container used by millions. We now use lpm to install JDBC drivers instead of explicitly downloading each one. This has made Dockerfile maintenance for new releases of JDBC drivers far easier. We love it and know you’ll probably love it, too.
How to use lpm
The first step in using lpm is to install it on your system.
- Download lpm for your appropriate system from our GitHub repository
- Unzip the release
- Copy the lpm binary to your favorite location
- Add the lpm location to your PATH environment variable
Adding the lpm installation directory to your PATH environment variable will make using lpm much easier.
Get the latest versions of JDBC drivers
update to ensure you always have the latest version of drivers available without needing to update the installed version of lpm.
apt-get update functionality.
Search for your required JDBC driver
For this example, we’ll use PostgreSQL. First, you need to search for available JDBC drivers using:
lpm search. Of course, this returns all of the available drivers and extensions. To narrow this down to the ones related to PostgreSQL, we issue
lpm search postgres and see the following:
C:\>lpm search postgres Package Category ├── postgresql driver └── liquibase-postgresql extension
Install your required JDBC Driver
Now we have found our PostgreSQL JDBC Driver and the package name is “postgressql”. To add the driver to our system, simply issue the following command in your Liquibase installation directory:
C:\dev\liquibase\liquibase-4.4.3>lpm add -g postgresql Checksum verified. Installing postgresql-42.2.23.jar to C:\dev\liquibase\liquibase-4.4.3\lib\ postgresql-42.2.23.jar successfully installed in classpath.
As you can see, lpm downloaded the appropriate PostgreSQL JDBC Driver, validated it against a verified Checksum, and copied it to the Liquibase `lib` directory.
A note on global- and project-level installations
lpm was built to provide you with the ability to install drivers for all users of the system. You can use the
-g global option to do just that. However, if you would like to simply copy to a local directory, not using the
-g option defaults to a local installation. This places the lpm packages in a
liquibase_libs directory. You will then need to update your JAVA_OPTS environment variable to take advantage of the downloaded packages. This would be useful on automated build systems where you do not have root access but Liquibase is already installed.
Let us know what you think
If you have questions about lpm, please join us on our Discord server. lpm is Apache 2.0 licensed open source and we are always happy to resolve issues and gladly accept pull requests in our GitHub repository.