我使用sqlFile包含一个sql脚本,该脚本使用oracle特定命令(NOCACHE,NO PARALLEL,类似的东西)创建表。我的master.xml文件包含所有sql脚本并执行它们。但是,当它检测到标记时,它会失败并打印此错误消息。
C:\update.bat master.xml
Migration Failed: cvc-complex-type.2.4.a: Invalid content was found starting with element 'sqlFile'.
One of '{
"http://www.liquibase.org/xml/ns/dbchangelog/1.9":preConditions,
"http://www.liquibase.org/xml/ns/dbchangelog/1.9":property,
"http://www.liquibase.org/xml/ns/dbchangelog/1.9":changeSet,
"http://www.liquibase.org/xml/ns/dbchangelog/1.9":include,
"http://www.liquibase.org/xml/ns/dbchangelog/1.9":includeAll
}' is expected.
我的master.xml非常简单
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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">
<sqlFile path="createUsers.sql"/>
</databaseChangeLog>
任何想法都将不胜感激。 提前谢谢。
答案 0 :(得分:7)
我对liquibase一无所知,但那是 XML Schema的优点:通过阅读XSD,我们可以推断出当我们提供databaseChangeLog时系统期望的内容。
如果您查看XSD,可以看到有效的<databaseChagneLog>
元素应该包含列出的元素(<preCondition>
,<property>
,<changeSet>
等...如错误消息中所述。
(从阅读XSD开始)<sqlFile>
元素应该包含在<changeSet>
中。
所以也许你只需要:
... Header + databaseChangelog and its Namespace =as previously
...
<changeSet>
<sqlFile path="createUsers.sql"/>
</changeSet>
</databaseChangeLog>
但如上所述,我对基础语义甚至liquibase的一般目的一无所知。因此,您可以参考liquibase文档以了解您可能需要声明的其他内容等(例如,XSD允许包括许多其他元素,如validCheckSum,preContidtion等)