Unable to set duplicateFileMode property in application.yaml for liquibase

676 Views Asked by At

I have a Java project with Liquibase library as database migration tool. When running migrations I'm facing the issue: "Found 2 files with the path 'db/changelog/db.changelog-master.yaml'" and a suggestion how to fix that: "You can limit the search path to remove duplicates with the liquibase.searchPath setting. Or, if you KNOW these are the exact same file you can set liquibase.duplicateFileMode=WARN."

I am able to set the property via static block like:

static {
      System.setProperty("liquibase.duplicateFileMode", "WARN");
    }

And that works fine. However, based on liquibase documentation, this should we set as Java property as well, I suppose this value should be set from application.yaml like this:

spring:
  liquibase:
    parameters:
      duplicate-file-mode: WARN

or

spring:
  liquibase:
    parameters:
      duplicateFileMode: WARN

The application fails with the initial error: "Found 2 files with the path 'db/changelog/db.changelog-master.yaml'"

2

There are 2 best solutions below

0
Roman Sobo On

That's an open issue in Liquibase project. Link to follow https://github.com/liquibase/liquibase/issues/3230

0
Maciej Nawrocki On

Other walkaround may be to apply this env variable in gradle

I added configuration to my build.gradle.kts:

  tasks.withType<Test> {
    environment("LIQUIBASE_DUPLICATE_FILE_MODE", "WARN") // because of bug: https://stackoverflow.com/questions/77301370/unable-to-set-duplicatefilemode-property-in-application-yaml-for-liquibase
  }

EDIT:

Does not work for all versions of liquibase-core

  • didn't work for 4.17.1, worked fine for 4.20.0