2
votes

I'm facing a problem with spring boot and mvn liquibase. I'm able to update and rollback liquibase via Tag when I submit changes with

mvn liquibase:update

and rollback them with

mvn liquibase:rollback -Dliquibase.rollbackTag=0.0.0 

Unfortunately I'm not able to start my spring boot app when I submit changes with liquibase:update.

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liquibase' defined in class path resource [org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration$LiquibaseConfiguration.class]: Invocation of init method failed; nested exception is liquibase.exception.MigrationFailedException: Migration failed for change set classpath:db/changelog/changelog-0.0.1.xml::0.0.1::

Which tells me that spring boot tries to run the changesets again.

When I take a look at the databasechangelog table, there a duplicated entries with different deployment_ids, could this be the problem?

Here's the screenshot

Ps: When I let Spring boot do the updating I can run the app, but I can't rollback via CLI :(

Here's my configuration in pom.xml

    <plugins>
        <plugin>
            <groupId>org.liquibase</groupId>
            <artifactId>liquibase-maven-plugin</artifactId>
            <version>3.6.3</version>

            <configuration>
                <driver>org.postgresql.Driver</driver>
                <url>connection/url>
                <username>user</username>
                <password>password</password>
                <promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
                <rollbackTag>0.0.0</rollbackTag>
                <changeLogFile>destination of rollback file</changeLogFile>
            </configuration>
        </plugin>
    </plugins>
</build>

in application.properties

spring.liquibase.change-log=classpath:db/changelog-master.xml spring.liquibase.test-rollback-on-update=true

I guess the tagging of changelog files is correct, because it wouldn't work in CLI either.

Thank you.

1

1 Answers

2
votes

I guess that classpath in maven is different from classpath in springboot app. Liquibase computes the classpath and stores it in some property in db (I don't know it's name). So when you prepare your db with maven, and then you run your app, the path to your files is different so for liquibase that means something like new changelog file.

You can fix this by adding logicalFilePath attribute to all your changelog files.