how to rename ignore and rename the folder path of my changeset in the includeAll
tag?
I read that I supposed to use logicalFilePath
. But I can't find any documentation about this.
Example if I want to scan my folder, and rename it when checking in the database checking, how should my logicalFilePath
supposed to be?
Folder Schema :
ParentFolder
|___ MiddleFolder
|______AnotherFolder
|___________ 1.sql
|___________ 2.sql
<includeAll path="ParentFolder" logicalFilePath="?" />
I want to ignore and rename the folder so that it would become 'NewFolder/1.sql' and 'NewFolder/2.sql' in my databasechangelog
This use case is described in Liquibase documentation covering the logicalFilePath
attribute. Consider two quotes:
You can specify the
logicalFilePath
attribute in the root section of the<databaseChangeLog>
in your changelog or in a specific changeset.
If code restructuring results in a new filepath for a changelog, the
logicalFilePath
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:
db/changelog/db.changelog-1.0.xml
- New location:
db/changelog-1.0/db.changelog.xml
The
logicalFilePath
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.
So, the main idea of logicalFilePath
is to give Liquibase the old paths to the changesets so that their generated IDs don't change after move. Your solution would depend on how exactly are you restructuring the projects:
ParentFolder/MiddleFolder/AnotherFolder/1.sql
, ParentFolder/MiddleFolder/AnotherFolder/2.sql
, and so on. This will work even if you decide to move the changelogs that were in the same folder to different folders, but you will not be able to use it in the same changelog with includeAll
in this case;logicalFilePath
on the top-level changelog:
<includeAll path="NewFolder" logicalFilePath="ParentFolder/MiddleFolder/AnotherFolder" />
In case of problems, let's get back to the docs one more time:
Liquibase uses the following pattern to create a unique identifier for a changeset:
id/author/filepath
.
Basically, all that you need to achieve is to just make this identifier the same as it was before the renamings.