Debugging Database Version Control Tools Cross-platform

Fixing my Liquibase

On my personal projects, I usually end up try to write in a way that can be run on multiple platforms for development purposes.  Deployment is almost always on a linux server/container for production, but for working on my project, I wanted to be able to use any of my machines.I currently use:

  • Desktop: Windows 10, using Windows Subystem Linux (Bionic/18.04) and PowerShell (depending)
  • Personal Laptop: Ubuntu 18.04
  • Work Laptop: Macbook Pro

The interesting thing is that I'll usually run into the most common pitfalls for cross-platform development work, and I get to learn a ton about how to fix those. The downside is that it's infuriating to pick apart code that you thought should "just work" since it was working fine 5 minutes ago but now it's not and hey what now this is broken.

Anyways, here's something I debuged recently:

Setup

The year? 2019.The project? A character management platform (https://sprawler-client.herokuapp.com/)I wanted to try some best practices, so in designing my db from the ground up, I went with PostgreSQL (what my current employer uses, and I wanted to get more comfortable). After reading this article about keeping your project under version control, I went with my company's current tool (liquibase).I don't have a Java background, so installing and setting this up was super foreign to me. So I set up the project so that it'd get working on my Windows/WSL machine. I installed the right JDK, downloaded the liquibase build and compiled everything.

Here's my project setup:

project
└── liquibase
    └── lib
        ├── postgresql-42.2.5.jar
        └── ...other jars

The Problem

I cloned the repo to my Linux machine and gave it a whirl to try and set up my database (this was supposed to be idempotent, right?).

Immediately I started getting errors. Can't find driver for PostgreSQL. I tried double-checking my classpath, thinking that it somehow wasn't picking up my project/lib folder.

The Solution

I floundered for several months before I found the fix: Add the driver to my liquibase installation's lib directory. This shouldn't have needed to happen, since the command I was running looked like this:

liquibase \
 --driver=org.postgresql.Driver \
 --classpath=./liquibase/lib \
 --username=<usr> \
 --password=<pwd> \
 --url="jdbc:postgresql://localhost:5432/<db>" \
 --changeLogFile="./liquibase/database_change_log.xml" \
 update

This was supposed to work by passing the classpath for the jar, and I'm not sure why it didn't get picked up, but that's an exploration for another day.

Edit

Figured out why it wasn't working. I had to set the classpath to be pointed at the .jar . Wasn't super clear to me from the documentation, but hey, now it works! --classpath=./liquibase/lib/postgresql-42.2.5.jar

-CL