【问题标题】:Unable to tag the database using Liquibase for future rollback无法使用 Liquibase 标记数据库以备将来回滚
【发布时间】:2017-12-31 20:36:59
【问题描述】:

我正在尝试使用标记数据库以供将来回滚,但出现以下错误:

将更新应用到数据库。这可能需要几分钟的时间 ... 运行 Liquibase 时出现意外错误:解析 ppsdb/ebidb_lb_upgrade_c43_sql_1.xml 的第 12 行第 6 列时出错:cvc-complex-type.2.4.a:发现以元素“sql”开头的无效内容。需要 '{"http://www.liquibase.org/xml/ns/dbchangelog/1.9":modifySql}' 之一。

这是我的变更集文件:

cat ebidb_lb_upgrade_c43_sql_1.xml

<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog/1.9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog/1.9
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-1.9.xsd">
<changeSet author="avnish_plsql_upgrade" id="1">
<tagDatabase tag="version_1.3"/>
<sql
        stripComments="false"
>
create table test (id number);
</sql>
</changeSet>
</databaseChangeLog>

当我从文件中删除 tagDatabase 标记时,我没有收到任何错误。 只有当我添加这个标签时,我才会遇到错误。 如果我在这里遗漏任何东西或犯任何错误,请告诉我。

【问题讨论】:

    标签: database version-control liquibase


    【解决方案1】:

    我也遇到过同样的问题。在没有任何喘息的情况下搜索了一段时间后,我决定看一下 XSD,看看元素是如何声明的。

    根据Liquibase documentation link,XSD 的最新版本是 3.1。

    如果查看 3.1 XSD,您会发现 tagDatabase 和其余的 changeSet 允许的元素是互斥的(它们是 XSD:CHOICE 的一部分)

    <xsd:choice>
                  <xsd:element ref="tagDatabase" maxOccurs="1"/>
                  <xsd:group ref="changeSetChildren" minOccurs="0" maxOccurs="unbounded"/>
    </xsd:choice>
    

    为了测试我的理论,我创建了一个新的changeSet,只有tagDatabase 元素,可以看到迁移成功,但显然第二个changSet 是唯一一个带有发布标签的标签。

    所以现在,我将对 DATABASECHANGELOG 表进行数据更新以更新标记列。

    我希望 liquibase 开发者推出一个新的 XSD 来解决这个问题。

    【讨论】:

      【解决方案2】:

      我认为问题可能在于您使用的是非常过时的 xsd。在 XML 文件的标头中,将所有 1.9 实例替换为 3.6

      这是我最近的一个环境中的一个例子:

      <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.6.xsd">
      

      【讨论】:

      • 按照 SteveDonie 的建议进行了更改。使用或不使用 tagDatabase 标记时出现以下错误:运行 Liquibase 时出现意外错误:解析 ppsdb/ebidb_lb_upgrade_c43_plsql.xml 的第 6 行第 136 行时出错:schema_reference.4:无法读取架构文档“liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd”,因为 1) 找不到文档; 2) 文件无法读取; 3)文档的根元素不是.
      • 您使用的是什么版本的 liquibase jar?您可能需要使用高于 1.9(非常旧)但低于 3.6(可能太新)的东西。
      • 我们的 liquibase 版本是 3.5.3。
      • 因此您可能应该使用“3.5”作为 XML 中 databaseChangelog 节点的 XSD 部分的版本。如果您尝试这样做但仍然失败,请再次发表评论。如果您尝试了它并且它有效,请将此作为正确答案。
      猜你喜欢
      • 2021-06-08
      • 2020-11-20
      • 1970-01-01
      • 2016-11-19
      • 1970-01-01
      • 2011-01-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多