无法使用Liquibase标记数据库以备将来回滚

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

我试图标记数据库以供将来回滚使用但得到以下错误:

将更新应用于数据库。这可能需要几分钟...运行Liquibase时出现意外错误:解析pps​​db / 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}'是预期的。

这是我的changeSet文件:

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
2个回答
0
投票

我认为问题可能是您使用的是非常过时的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">

0
投票

我一直面临同样的问题。在没有任何喘息的情况下搜索了一会儿之后,我决定看看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是唯一标记有释放Tag的人。

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

我希望liquibase家伙推出一款新的XSD来解决这个问题。

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