[英]How can we use xinclude in Liquibase XML changlelog?
I am trying to include another xml file which is a fragement of XML file into my changelog.我正在尝试将另一个 xml 文件包含在我的更改日志中,该文件是 XML 文件的一个片段。 Whenever I execute my changelog in liquibase it gets executed successfully (without any parsing error) but no table is created in the database.
每当我在 liquibase 中执行我的更改日志时,它都会成功执行(没有任何解析错误),但没有在数据库中创建表。
I am not sure we can use xInclude in liquibsae, but I think it should be possible as we are using xml underneath in liquibase.我不确定我们是否可以在 liquibsae 中使用 xInclude,但我认为这应该是可能的,因为我们在 liquibase 中使用了 xml。 Plus I coulndt find any example of xinclude in liquibase and in offical documentation.
另外,我在 liquibase 和官方文档中找不到任何 xinclude 示例。
Changelog.xml变更日志.xml
<?xml version="1.0" encoding="UTF-8"?>
<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"
xmlns:xi="http://www.w3c.org/2001/Xinclude">
<changeSet id="id-1234"
author="umarTahir">
<comment>creates table: employee</comment>
<xi:include
href="employee.xml" parse="xml"
xpointer="title"/>
<rollback>
<dropTable schemaName="employee_test" tableName="employee" />
</rollback>
</changeSet>
</databaseChangeLog>
employee.xml员工文件
<createTable tableName="employee" xml:id="title">
<column name="employee_id" type="UUID">
<constraints primaryKey="true"
primaryKeyName="employee_pkey" />
</column>
<column name="first_name" type="TEXT" />
<column name="middle_name" type="TEXT" />
<column name="last_name" type="TEXT" />
<column name="email" type="TEXT" />
<column name="n_created_by" type="TEXT" />
<column name="n_created" type="TIMESTAMP WITHOUT TIME ZONE" />
<column name="n_last_modified_by" type="TEXT" />
<column name="n_last_modified"
type="TIMESTAMP WITHOUT TIME ZONE" />
</createTable>
Correct me if I'm wrong, but as far as I understand, liquibase parses changeLogs based on dbchangelog-{version}.xsd
.如果我错了,请纠正我,但据我所知,liquibase 基于
dbchangelog-{version}.xsd
解析 changeLogs。
<xi:inlude>
is being ignored. <xi:inlude>
被忽略。 In fact, even if you type <xi:foo-bar>
the changeLog still will be parsed successfully, but <xi:...>
will be ignored.事实上,即使你输入
<xi:foo-bar>
,changeLog 仍然会被成功解析,但<xi:...>
将被忽略。
So, I'd suggest to use <include>
tag to include content from other changeLog files or use <sqlFile>
to include sql files.所以,我建议使用
<include>
标签来包含来自其他 changeLog 文件的内容或使用<sqlFile>
来包含 sql 文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.