最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

how to use liquibase includeAll with logicalFilePath? - Stack Overflow

programmeradmin2浏览0评论

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

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

Share Improve this question edited Mar 16 at 13:12 Mark asked Mar 14 at 12:15 MarkMark 2,0332 gold badges21 silver badges43 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1 +50

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:

  • in general, the safest bet is to set the logical file path individually for each changelog (or changeset - we don't know your structure) so that it points to the specific file, like 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;
  • to address the latter, if you preserve the structure of the changelogs while renaming only the intermediate folders, you might want to try to set the old path as the value of 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.

发布评论

评论列表(0)

  1. 暂无评论