Liquibase and Spring Boot

I think it’s great that Spring Boot has built-in support for Liquibase but I think there is missing documentation on it. Some of it is on Spring’s part and others are in Liquibase. I hope to demystify it a bit.

Spring Boot’s default master change log is db/changelog/db.changelog-master.yaml . Note the file extension is yaml not the standard yml. No idea why they did it that way.

For database migrations, I don’t like storing everything in one changelog file. Instead I like putting them in different files in a folder. Liquibase has an includeall directive but only documents it in XML. Not sure how I figured this out but here is how I did it with yaml:

databaseChangeLog:
   - includeAll:
       path: classpath*:db/changelog/changes/

So now I can store my changes in classpath*:db/changelog/changes/ with any format that I want.

Lastly you can use Spring Intializr to put Liquibase in your project but, oddly, it doesn’t include the Liquibase plugin if you pick Maven or Gradle, which means that you don’t have Liquibase commands in your build file. So be aware that, regardless of your build tool, you will have to do more work to get things as workable as it should be.

About the Author

Object Partners profile.

One thought on “Liquibase and Spring Boot

  1. Gustavo says:

    classpath*:db/changelog/changes/ exactly what I was looking for. Thank you!

  2. Brendan says:

    I had trouble using `classpath:` in my configuration because the liquibase-maven-plugin starts by searching the classpath.

Leave a Reply

Your email address will not be published.

Related Blog Posts
Natively Compiled Java on Google App Engine
Google App Engine is a platform-as-a-service product that is marketed as a way to get your applications into the cloud without necessarily knowing all of the infrastructure bits and pieces to do so. Google App […]
Building Better Data Visualization Experiences: Part 2 of 2
If you don't have a Ph.D. in data science, the raw data might be difficult to comprehend. This is where data visualization comes in.
Unleashing Feature Flags onto Kafka Consumers
Feature flags are a tool to strategically enable or disable functionality at runtime. They are often used to drive different user experiences but can also be useful in real-time data systems. In this post, we’ll […]
A security model for developers
Software security is more important than ever, but developing secure applications is more confusing than ever. TLS, mTLS, RBAC, SAML, OAUTH, OWASP, GDPR, SASL, RSA, JWT, cookie, attack vector, DDoS, firewall, VPN, security groups, exploit, […]