【问题标题】:liqubase: generate sql script from changelog xml without db connectionliquibase:从没有数据库连接的 changelog xml 生成 sql 脚本
【发布时间】:2018-09-19 16:46:02
【问题描述】:

我有一个 liqubase changelog.xml。它包括一些带有更改的“包含文件”。 例如,创建一个表的基本脚本和向该表添加新字段的另一个脚本。

我可以使用一个“创建表...”语句获取包含所有字段的 sql-script。而且我不想连接到数据库。只需使用 liquibase xml 文件和 jar 库。

版本 liquibase - 3.5.5。

我尝试运行执行此命令: java -jar liquibase-core-3.5.5.jar --url=offline:mssql?outputLiquibaseSql=true --changeLogFile="changelog.xml" --outputFile="all.sql" updatesql

changelog.xml:

<?xml version="1.0" encoding="UTF-8"?>
<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">
    <include file="base.sql" relativeToChangelogFile="true"/>
    <include file="changelog_20180719.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>

但 all.sql 仅包含第一个包含文件 (base.sql) 中的 sql

谢谢

【问题讨论】:

    标签: sql liquibase generate


    【解决方案1】:

    您可以这样做,您需要使用“离线”连接 URL。以这个最近的问题为例。如果您的目标是不同的数据库,则 URL 会有所不同。 liquibase databasechangelog table in updateSql mode

    【讨论】:

    • 感谢您的指导。
    • 但似乎对于少数包含的文件,例如: liquibase.org/xml/ns/dbchangelog/1.9" xmlns:xsi="w3.org/2001/XMLSchema-instance" xsi:schemaLocation="liquibase.org/xml/ns/dbchangelog/1.9 liquibase.org/xml/ns/dbchangelog/dbchangelog-1.9.xsd" > 脚本仅包含 base.sql 的表和字段...
    • 评论不是提出后续问题的好地方。此外,在 StackOverflow 上提问时,通常最好包含更多细节 - 您提供的确切命令、使用的软件版本、预期结果和实际结果。
    • 谢谢@stevedonie。你说得对。我在我的问题中添加了具体信息
    猜你喜欢
    • 2015-02-25
    • 2023-04-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-09
    • 1970-01-01
    • 1970-01-01
    • 2017-05-24
    相关资源
    最近更新 更多