使用Liquibase在离线模式下为空数据库生成更改日志
问题描述:
如标题所示,我想使用Liquibase在脱机模式下为空数据库生成更改日志。我的Ant文件如下所示:使用Liquibase在离线模式下为空数据库生成更改日志
<project xmlns:liquibase="antlib:liquibase.integration.ant">
<taskdef resource="liquibase/integration/ant/antlib.xml" uri="antlib:liquibase.integration.ant">
<classpath>
<pathelement location="antlibs/liquibase-core-3.5.3.jar" />
<pathelement location="antlibs/snakeyaml-1.18.jar" />
</classpath>
</taskdef>
<target name="generate-changelog">
<liquibase:generateChangeLog>
<liquibase:database url="offline:postgresql?snapshot=snapshot.json" />
<liquibase:xml outputfile="target/changelog.xml" encoding="UTF-8" />
</liquibase:generateChangeLog>
</target>
后来我想补充Liquibase-Hibernate4来从我的实体的更新日志,但我之前遇到的各种问题。如果我简单地使用url“offline:postgresql”,则由于Liquibase试图克隆不可用的快照,因此ant任务会崩溃并出现NullPointerException。如果我添加“?snapshot = snapshot.json”,Liquibase(或Yaml)无法找到我的文件。
我的问题:
- 这时候我只是想,没有任何基础的快照都创建我的实体changelog的正确的方法?
- 有没有更容易的方法来提供一个空的数据库liquibase作为基地?
- 如何将snapshot.json添加到项目以确保蚂蚁任务可以找到它?
答
在此期间,我能够找出一些事情:
- 为了确保snapshot.json可以通过任务可以发现,人们必须把它放到一个jar文件,并添加jar文件到任务的类路径。
- 它似乎不是Hibernate扩展的正确方法,因为Hibernate扩展似乎不适用于脱机URL。
- 根据https://liquibase.jira.com/browse/CORE-2183,可能的解决方法是使用空H2数据库作为生成初始JPA更新日志的基础。