I'm stuck with a silly but annoying problem with implementing Liquibase to my existing project. After a lot of struggling I got it to work when starting the application, it runs through the master changelog and the included changelogs/changesets.
The problem then occurred when I was adding the Luquibase Gradle plugin (which also is needed for future support) because the can't find the changelog file with the same path.
When running the application through settings in application.yml file the changelog needs to be:
changeLog: classpath:/db/changelog-master.yml
to work (else the file can't be found) and the path in my changelog-master file is:
databaseChangeLog:
- include:
file: db/changelog/changelog.yml
But if I use plugin commands (changelogSync for example) the path needs to be from the src, like:
src/main/resources/db/changelog-master.yml
for the plugin to find the changelog.
Would really appreciate some help to be able to use Liquibase both when starting the application and when using commands with the plugin but I can't seem to find a way around this silly thing.
My activities in build.gradle is like this:
liquibase {
activities {
main {
File propsFile = new File("${project.rootDir}/src/main/resources/liquibase.properties")
Properties properties = new Properties()
properties.load(new FileInputStream(propsFile))
changeLogFile properties['changeLogFile']
url properties['url']
username properties['username']
password properties['password']
}
}
}
And the Liquibase setup in application.yml is:
spring:
liquibase:
enabled: true
changeLog: classpath:/db/changelog-master.yml
There just must be an easy solution to this that I just can't seem to find? Feel free to ask for more code snippets but the rest is quite straightforward according to the documentation from Liquibase with the liquibase.propterties file etc in my setup.
I’m using Liquibase core v. 3.8.9 and plugin version 2.0.3.
Thanks.