liquibase 标记变更集已应用

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

如何将特定变更集标记为在 liquibase maven 插件中应用?文档中没有任何相关内容,命令 markNextChangeSetRan 似乎什么也没做。

maven liquibase
4个回答
4
投票

这个问题有一个“hacky”解决方案:

  1. 删除有问题的
    changeSet
    XML 元素的所有子元素。请记住将
    changeSet
    及其 id 和作者参数保留在 liquibase XML 文件中。
  2. 奔跑
    mvn liquibase:update
    • 应该说它运行了所需的特定
      changeSet
  3. 恢复您修改的 XML 文件。
  4. 再次运行
  5. mvn liquibase:update
    
    
      您将获得
    • Validation Failed: 1 change sets check sum
       新的金额。复制错误中的新校验和。
  6. 手动将校验和粘贴到目标数据库
  7. DATABASECHANGELOG
    表中的右侧记录中。

1
投票
查看当前主分支(当前为 3.0.0-beta2-SNAPSHOT)中的

sources ,似乎根本没有实现 markNextChangeSetRan

 命令。 

所以我想,它根本不存在。

您可以在

liquibase JIRA 中添加票证来请求此操作,但似乎没有 Maven 插件的项目(但不知道 liquibase 的 Maven 插件是否在其他地方跟踪)。

抱歉没有更好的答案。我刚刚从

github 亲自查看了完整的 liquibase 代码,以实现缺少的功能,所以我想我只是快速检查一下。


1
投票
您可以运行

mvn liquibase:changelogSyncSQL

 生成一组 SQL 语句,将您的变更集标记为已应用。

它将把查询放入

target/liquibase/migrate.sql

。然后,您可以在数据库中手动执行这些 SQL 语句。

https://b-gyula.github.io/liquibase-doc/documentation/existing_project


0
投票
您可以在变更集中添加前提条件,如下所示:

<changeSet author="bernd" id="1"> <preConditions onFail="MARK_RAN"><not><changeLogPropertyDefined property="should_be_ignored" value="true"/></not></preConditions> ... </changeSet>
如果属性“should_be_ignored”设置为“true”,则此变更集将不会被执行,而是会在 DATABASECHANGELOG 表中标记为“MARK_RAN”。

此外,您还可以在 liquibase 文件夹中创建一个额外的根

changeset.xml

 文件,该文件定义此属性,并包含常规 
changeset.xml

<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd"> <!-- we only mark changesets with a pre-condition on this property as executed, but we do not execute them! !--> <property name="should_be_ignored" value="true" /> <include file="changelog.xml" relativeToChangelogFile="true"/> </databaseChangeLog>
然后您可以使用 

changelog.xml

 或使用此 
changelog2.xml
 启动应用程序,它将应用/不应用那些特定的变更集。

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