Rollback script isn't generated by maven plugin in case of liquibase initialized DB by Spring

Hello Everyone,

I have an application built on top of Spring Boot + Liquibase, where Liquibase configured the following way:

@Configuration
public class LiquibaseConf {

  @Bean
  public SpringLiquibase liquibase(DataSource ds) {
    SpringLiquibase springLiquibase = new SpringLiquibase();
    springLiquibase.setChangeLog("classpath:db/init-changelog.xml");
    springLiquibase.setDataSource(ds);
    return springLiquibase;
  }
}

Recently, I decided to build CI pipeline with possibility to rollback to the previous app version which may require rollback of DB changes.
Rollback of DB changes I was going to do via liquibase-maven-plugin i.e. use the following command:
mvn liquibase:rollbackSQL -Dliquibase.rollbackTag=<release_version> where<release_version> is previous release…

Sample of pom.xml file:

...
<build>
   <pluginManagement>
      <plugins>
         <plugin>
            <groupId>org.liquibase</groupId>
            <artifactId>liquibase-maven-plugin</artifactId>
            <version>${liquibase.version}</version>
            <configuration>
               <changeLogFile>/src/main/resources/db/init-changelog.xml</changeLogFile>
               <driver>org.postgresql.Driver</driver>
               <url>jdbc:postgresql://${env.DB_HOST}:${env.DB_PORT}/${env.DB_NAME}</url>
               <username>${env.DB_USER}</username>
               <password>${env.DB_PASSWORD}</password>
               <verbose>true</verbose>
            </configuration>
            <executions>
               <execution>
                  <phase>process-resources</phase>
                  <goals>
                     <goal>rollback</goal>
                  </goals>
               </execution>
            </executions>
         </plugin>
      </plugins>
   </pluginManagement>
</build>
---

The issue that I faced right now is that when DB is initialized by Liquibase via Spring Boot values of filename column in databasechangelog table have classpath: prefix which causes issues when I try to generate rollback script via liquibase maven plugin, as it looks like it expects absolute path to the file names, i.e. c:\app\src\main\resources\db\v02\temp.xml instead of classpath:db/v02/temp.xml.

In my case result is aways the same, plugin generates:

-- Lock Database
UPDATE databasechangeloglock SET LOCKED = TRUE, LOCKEDBY = 'PC (100.64.46.243)', LOCKGRANTED = '2023-02-22 16:05:35.847' WHERE ID = 1 AND LOCKED = FALSE;

-- Release Database Lock
UPDATE databasechangeloglock SET LOCKED = FALSE, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1;

Just for testing purposes, I also tried to initialize DB via mvn liquibase:update command and only after that was able to generate rollback script, but it’s not what I want.

I would like to continue using Spring Boot + Liquibase to manage DB schema and rollback DB changes via maven plugin. Please suggest me a solution to overcome this issue.

Thanks,
Uladzimir

Ok, it looks like I found a workaround for the issue - update Liquibase to the latest version from 3.6.3 that I was using… Not sure why, but after upgrade Liquibase no longer adds classpath: prefix and after specifying in plugin relative path to the changelog file to match to what in the DB, I was finally able to generate rollback script.