logical-file-path

The logical-file-path attribute is used to override the file name and path when creating the unique identifier of changesets. The logical-file-path attribute is required when moving or renaming changelogs to prevent Liquibase from redeploying the corresponding changesets as their unique identifier will have been changed by the move.

You can specify the logical-file-path attribute in the root section of the <databaseChangeLog> in your changelog or in a specific changeset.

Uses

Liquibase uses the following pattern to create a unique identifier for a changeset: id/author/filepath.

Even if the same file is referenced by a different filepath it is considered a different file by Liquibase because of the unique identifier definition. The logical-file-path attribute is used to override this behavior for one of the following purposes.

You have multiple developers sharing a changelog file

If multiple developers are sharing a changelog file and their filepaths are not identical, Liquibase may attempt to repeat the execution of the changesets to the target database unless the logical-file-path is used.

Here are some example filepaths for two developers:

  • /Users/developer-1/release1.0/db.changelog.xml

  • /Users/developer-2/release1.0/db.changelog.xml

The logical-file-path would need to be used in this example to override the specific developers filepath so that Liquibase would not attempt to rerun the changeset files.

Code restructuring results in a new filepath for the changelog

Another example of when logical-file-path must be used is during code restructuring. If code restructuring results in a new filepath for a changelog, the logical-file-path attribute can be used to prevent Liquibase from attempting to rerun the previously deployed changesets.

In this example, a changelog is being moved:

  • Previous Location: /src/main/resources/db/changelog/db.changelog-1.0.xml

  • New Location: /src/main/resources/db/changelog-1.0/db.changelog.xml

The logical-file-path for the changelog would need to be set to /src/main/resources/db/changelog/db.changelog-1.0.xml to prevent Liquibase from redeploying the changesets to the database.

You want to prevent changeset id conflicts between modules

The logical-file-path can also be used as a unique identifier to prevent duplicate changeset ids between modules from causing Liquibase collisions.

Setting the logical-file-path attribute

The logical-file-path attribute should be specified relative to the classpath if providing a directory structure. It can also be specified without a filepath, for example path-independent, to remove directory structure considerations.