liquibase 未来回滚错误,带有 sqlFile 标签:找不到文件
我已将 future-rollback 标签添加到我的 ant 脚本中。我想要做的(我认为未来回滚就是我正在寻找的)是生成一个sql回滚脚本,但不执行它(回滚脚本必须与sql脚本一起交付是来自的要求我的客户)。
我的变更日志文件有许多变更集,其中一些包含
标记。
例如:
其中 latest/somesqlprocedure.xml
具有 sqlFile
标记。
<代码>
当我运行 ant 脚本时,出现以下错误
liquibase.exception.ChangeLogParseException: 无效的迁移文件:
- 找不到文件
有人知道发生了什么事吗?
这是 build.xml 文件的片段
<target name="db-future-rollback" depends="init">
<rollbackFutureDatabase
changeLogFile="${db.changelog.file}"
driver="${database.driver}"
url="${database.url}"
username="${database.username}"
password="${database.password}"
outputfile="${database.rollback.dir}"
promptOnNonLocalDatabase="${prompt.user.if.not.local.database}"
classpathref="project.classpath"
>
</rollbackFutureDatabase>
</target>
提前致谢。
I've added the future-rollback tag to my ant script. What i want to do (and I think future-rollback is what Im looking for) is to generate an sql rollback script, but without executing it (rollback script must be delivered with sql scripts is the requirement from my client).
My changelog file has many changesets, some of which contain the <sqlFile>
tag.
For example:
<databaseChangeLog ...>
<include file="latest/somesqlprocedure.xml" relativeToChangelogFile="true"/>
</databaseChangelog...>
Where the latest/somesqlprocedure.xml
has an sqlFile
tag.
<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="${changelog.dir}/latest/myprocedure.sql" splitStatements="false" />
</changeSet>
</databaseChangeLog>
When I run the ant script, I get the following error
liquibase.exception.ChangeLogParseException:
Invalid Migration File:<sqlfile
path=${changelog.dir}/latest/myprocedure.sql>
- Could not find file
Does anyone has an idea of whats going on ?
This is a snippet of the build.xml file
<target name="db-future-rollback" depends="init">
<rollbackFutureDatabase
changeLogFile="${db.changelog.file}"
driver="${database.driver}"
url="${database.url}"
username="${database.username}"
password="${database.password}"
outputfile="${database.rollback.dir}"
promptOnNonLocalDatabase="${prompt.user.if.not.local.database}"
classpathref="project.classpath"
>
</rollbackFutureDatabase>
</target>
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题可能来自于在 sqlFile 中使用绝对路径,而不是类路径相对路径。 liquibase 最初支持 classpath 相对路径,并且仍然经过了更好的测试。最近添加了绝对路径选项,futureRollbackSql 代码可能尚未修补以支持它。
您可以尝试使用相对路径的 sqlFile 吗?
附带说明一下,相对路径选项通常更好,因为数据库更改日志表中使用文件名来记录哪些更改集已运行。如果您使用绝对路径,则会存储整个路径,并且如果您尝试从不同的路径重新运行变更日志(或从不同的机器针对同一数据库运行),liquibase 会认为这是一个不同的变更集并尝试重新运行它。
The problem may be coming from using an absolute path in your sqlFile, rather than a classpath-relative path. The classpath relative path was what was originally supported in liquibase and is still better tested. The absolute path option was added recently, and the futureRollbackSql code may have not been patched to support it.
Can you try the sqlFile using a relative path?
As a side note, the relative path option is generally better because the filename is used in the databasechangelog table to note which changeSets have ran. If you use an absolute path, the entire path is stored and if you try to re-run the changelog from a different path (or running against the same database from a different machine), liquibase will think it is a different changeSet and try to re-run it.