Liquibase includeAll tag is ignored

2019-05-06 16:28发布

问题:

Here we go..

We have a Spring Boot 1.4.0 application and we're using Liquibase 3.5.1 for our DB management.

All of our individual changeset files are located in /src/main/resources/db/changelog and they have the following naming schema: [semanticVersion]-[descriptor].yml

The master changelog, however, is located inside a runtime dependency.

db.changelog-master.yaml

databaseChangeLog:
  - changeSet:
      id: 1.0.1
      author: atlassian
      changes:
        - createTable:
            //code omitted for brevity
  - includeAll:
      path: classpath*:db/changelog
      errorIfMissingOrEmpty: false

Now to the problem.

Running the application through IDEA all of the changesets are loaded and applied to our DB.

However when I use the Spring Boot Gradle plugin to build a fat jar (bootRepackage task) and then proceed to run it with java -jar [project].jar the master changelog is found, the table is created but all the other files are seemingly.. ignored. databasechangelog table only shows the 1.0.1 update and that's it. Fun fact, if I set the error property to true it only fails once I also fudge the path to something unresolvable. So it seems like the directory is found just fine.

NB! All the .yml files are inside the fat jar, checked and double-checked :)

I have also tried renaming them to .yaml, I've tried replacing them with corresponding .xml files, nothing is resolved.

I dug around on Google, Stack and Liquibase JIRA and found out only a handful of mentions of this happening and from what I read, on 3.5.1 this problem should've been fixed.. but no dice.

If I switch the Liquibase dependency back to 3.4.2 (which was mentioned as a possible solution) and run the jar I get a few thousand lines of exceptions that culminate with an Exception saying that db.changelog-master.yaml is not recognized as a proper file and DatabaseChangeLog node cannot be found.

If I missed any important information just let me know, I tried to be as verbose as possible.

回答1:

This seems to be fixed in a later version of liquibase than what is currently set by spring boot.

Override the version via:

ext["liquibase.version"] = "3.5.4"

Also, know that this issue still exists in spring boot 1.5

Ref: https://liquibase.jira.com/browse/CORE-2863