Rollback using different folder path

As we need to cater for switching between feature branches and ensuring the database is consistent with the changesets included in only the current feature branch, we looked at copying the changesets deployed by one feature branch to a global rollback folder.

The idea is this, liquibase would pick up on the unexpected changesets, then we would do a rollback of those changeset(s) using a path option to direct it to exactly the same changelog file, albeit in a different location.

What is the recommended way of doing this on a Windows OS?

Currently I have:

  1. Master merged release changelogs in ./changelog/release
  2. I have the “rollback” changelogs from previous feature branch(es) in C:/Projects/liquibase/rollbackstore

I tried to add the absolute path to the searchPath property in the properties file.
I tried to specify the path using the --changelog-file parameter.
I tried to include the path in the changelog root.

The best I could get is the liquibase terminal window showing no errors, but also showing that there were 0 changesets to rollback when I had issued the rollback command. If I add the changelog file to the original path (same as recorded in the FILENAME field of the DATABASECHANGELOG table) then obviously it rolls back perfectly. Totally puzzled by this, and the array of unrelated errors I get when using the searchPath property. Is it possible to rollback changesets, if the same file is located in another folder?

Hi everyone,

I got this predicament solved. The answer was to decorate each changelog with the LogicalFilePath property, and then it doesn’t matter which folder it is in, as long as the changelog root includes the folder for reference.

As I am using sql formatted changelogs, the header looks something like this:

-- liquibase formatted sql logicalFilePath:audit/release/release-1.0.sql

Thank You.