【问题标题】:Liquibase ChangeSet not found when using rollback tag with changeSetId and changeSetAuthor使用带有 changeSetId 和 changeSetAuthor 的回滚标记时找不到 Liquibase ChangeSet
【发布时间】:2016-05-13 22:07:18
【问题描述】:

我正在使用 Liquibase 3.4.2(通过 Maven 插件)。我有一个 db.changelog-master.xml 文件,其中包含另外两个文件:db.changelog-2.6.xmldb.changelog-2.10 >.

db.changelog-master.xml 看起来像这样:

<?xml version="1.0" encoding="UTF-8"?> 
<databaseChangeLog logicalFilePath="/database-migration/db.changelog-master.xml"
               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.4.xsd">
    <include file="versions/db.changelog-2.6.xml" relativeToChangelogFile="true"/>
    <include file="versions/db.changelog-2.10.xml" relativeToChangelogFile="true"/>

</databaseChangeLog>

db.changelog-2.10中,我创建了一个&lt;changeSet&gt; 来删除一些数据,并且在&lt;rollback&gt; 标记中我引用了创建相同数据的&lt;changeSet&gt;。两个&lt;changeSet&gt; 看起来像这样:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<databaseChangeLog logicalFilePath="/database-migration/versions/db.changelog-2.10.xml"
               xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
               xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
               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.4.xsd">
    <changeSet id="1" author="my-user">
        <insert tableName="TABLE">
            <!-- SOME DATA -->
        </insert>
    </changeSet>

    <changeSet id="2" author="my-user">
        <delete tableName="TABLE" />
        <rollback changeSetId="1" changeSetAuthor="my-user" />
    </changeSet>
</databaseChangeLog>

问题是,当我尝试运行 update 命令时,我最终收到以下错误消息:

变更集 /database-migration/versions/db.changelog-2.10.xml::1::my-user 不存在

是我做错了什么还是这是一个 Liquibase 错误?

【问题讨论】:

    标签: liquibase


    【解决方案1】:

    请检查&lt;changeSet id="1"&gt; 中打开和关闭 XML 标记的匹配。在您的示例中,我看到了开始标签&lt;insert&gt; 和结束标签&lt;/update&gt;。也许您的问题是由于输入数据不正确造成的。很奇怪,liquibase 中的 XML-parser 没有检测到这一点。

    尝试将结束标记&lt;/update&gt; 替换为更合适的&lt;/insert&gt;

    【讨论】:

      【解决方案2】:

      添加changeSetPath属性

      change_log_master: ... <include file="scripts/my_rollback_script.xml"/> <include file="scripts/the_script_change_log.xml"/> ...

      the_script_change_log.xml: ... <rollback changeSetId="my_rollback_script_id" changeSetAuthor="me" changeSetPath="scripts/my_rollback_script.xml" /> ...

      【讨论】:

        猜你喜欢
        • 2011-01-15
        • 1970-01-01
        • 2012-06-10
        • 2016-11-19
        • 1970-01-01
        • 2017-12-31
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多