liquibase 未来回滚错误,带有 sqlFile 标签:找不到文件

发布于 2024-08-21 03:06:49 字数 1951 浏览 4 评论 0原文

我已将 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不寐倦长更 2024-08-28 03:06:50

问题可能来自于在 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文