使用 MongoDB 将标签添加到 Liquibase PRO 中的特定变更集

问题描述 投票:0回答:1

我有

databaseChangeLog:
    - changeSet:
          id: add_game_interests
          author: tiago
          runWith: mongosh
          changes:
              - mongoFile:
                    dbms: mongodb
                    path: add_game_interests.js
                    relativeToChangelogFile: true
          rollback:
              - mongoFile:
                  dbms: mongodb
                  path: delete_game_interests.js
                  relativeToChangelogFile: true
          tagDatabase:
              - tag: 0.0.1

但是得到

Caused by: liquibase.exception.LiquibaseException:
In changeset 'add_game_interests::tiago' there is an unsupported change type 'tagDatabase'.
A  changeset with runWith='mongosh' attribute may only contain mongo or mongoFile change types. Learn more at https://docs.liquibase.com
        at liquibase.changelog.ChangeLogIterator.validateChangeSetExecutor(ChangeLogIterator.java:193)
        at liquibase.changelog.ChangeLogIterator$2.lambda$run$0(ChangeLogIterator.java:129)
        at liquibase.Scope.lambda$child$0(Scope.java:186)
        at liquibase.Scope.child(Scope.java:195)
        at liquibase.Scope.child(Scope.java:185)
        at liquibase.Scope.child(Scope.java:164)
        at liquibase.changelog.ChangeLogIterator$2.run(ChangeLogIterator.java:122)
        at liquibase.Scope.lambda$child$0(Scope.java:186)
        at liquibase.Scope.child(Scope.java:195)
        at liquibase.Scope.child(Scope.java:185)
        at liquibase.Scope.child(Scope.java:164)
        at liquibase.Scope.child(Scope.java:252)
        at liquibase.Scope.child(Scope.java:256)
        at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:89)
        ... 26 more

然后尝试了

databaseChangeLog:
    - changeSet:
          id: add_game_interests
          author: tiago
          runWith: mongosh
          changes:
              - mongoFile:
                    dbms: mongodb
                    path: add_game_interests.js
                    relativeToChangelogFile: true
          rollback:
              - mongoFile:
                  dbms: mongodb
                  path: delete_game_interests.js
                  relativeToChangelogFile: true
    - changeSet:
          id: add_game_interests_tag
          author: tiago
          tagDatabase:
              - tag: 0.0.1

虽然添加了标签,但它不会将标签添加到前一个具有 id 的标签

add_game_interests

mongodb liquibase liquibase-cli liquibase-pro
1个回答
1
投票

虽然添加了标签,但它不会将标签添加到前一个具有 id 的标签

add_game_interests

也不应该。

tagDatabase
是一种单独的更改类型,它将标记应用于当前模式状态,而不是特定的更改集:

当您想要标记当前数据库状态、版本或版本,然后将新的变更集部署到该标记或回滚在该标记之后应用的变更集时,通常可以使用 tagDatabase 更改类型。

此外,文档中有一个具体注释,强调它不应该像您的示例中那样使用:

注意:XSD 不允许 tagDatabase 更改类型与同一更改集中的其他更改类型一起使用。

这是因为以下原因,以及 Liquibase 的一般工作原理:

如果您从变更日志部署

tagDatabase
变更集,它会向 DATABASECHANGELOG 表添加一个新行。该行将具有该变更集中指定的标签名称。

© www.soinside.com 2019 - 2024. All rights reserved.