【发布时间】:2020-09-04 13:17:03
【问题描述】:
根据 Liquibase 官方网站上的This guide,我创建了自己的changelog-master.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="https://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd">
<includeAll path="/home/username/liquibase/examples/sqlite-test" filter="sql"/>
</databaseChangeLog>
然后我在同一文件夹中创建了liquibase.properties 文件:
# Enter the path for your changelog file.
changeLogFile=changelog-master.xml
#### Enter the Target database 'url' information ####
url=jdbc:sqlite://home/username/liquibase/examples/sqlite-test/testdb
这是正确的,因为如果我运行正常的 .sql 更改日志,它会正确运行并更新我的数据库。
然后我在 sql 中创建了一个更改日志文件,该文件必须在启动 liquibase update 时自动执行,即 000020-changelog.sql
--liquibase formatted sql
--changeset daniel:3
create table phonebook(name TEXT, surname TEXT, type TEXT, phone_number TEXT);
但是当我启动 liquibase update 时,我从 XML 解析器中得到一个错误:
运行 Liquibase 时出现意外错误:cvc-elt.1.a:找不到元素“databaseChangeLog”的声明。
而且我不明白问题出在哪里。我已经多次检查changelog-master.xml 文件是否正确并且看起来是正确的。从我可以找到的cvc-elt.1.a 是一个XML 解析错误,就像databaseChangeLog 它没有在xml 架构中声明。
我这样做是为了在将来我可以创建任意数量的变更日志,并让它们一个接一个地自动执行。
我一直在为这个问题寻找一些解决方案,但我找不到任何东西。我找到了官方论坛的链接,但现在是死链接。
额外信息:
- Liquibase 4.0.0 版
- 安装的 JRE:openjdk 11.0.8 2020-07-14
- 操作系统:Debian 10
- SQLite 版本 3.27.2
2020 年 8 月 9 日编辑:
根据 cmets 的要求,这是项目的结构:
root@dev-machine:/home/username/liquibase/examples/sqlite-test# ls -la
total 68
drwxr-xr-x 2 root root 4096 Sep 4 17:28 .
drwxr-xr-x 5 username username 4096 Sep 4 17:02 ..
-rw-r--r-- 1 root root 139 Sep 4 13:35 000020-changelog.sql
-rw-r--r-- 1 root root 118 Sep 4 13:36 000030-changelog.sql
-rw-r--r-- 1 root root 201 Sep 4 17:05 000040-changelog.sql
-rw-r--r-- 1 root root 240 Sep 4 17:28 000050-changelog.sql
-rw-r--r-- 1 root root 456 Sep 4 14:22 changelog-master.xml
-rw-r--r-- 1 root root 2637 Sep 4 16:36 liquibase.properties
-rw-r--r-- 1 root root 32768 Sep 4 17:28 testdb
testdb 是我用来测试 liquibase 的 sqlite 数据库。 .sql 文件是更新数据库必须运行的连续更改日志
【问题讨论】:
-
您能否也包括项目结构,即更改日志主文件的路径是否正确设置?
-
嗨@sudo 我刚刚用项目结构更新了帖子
标签: xml-parsing liquibase