简体   繁体   English

您可以从 SQL 代码生成 Liquibase 更改日志 XML 文件吗?

[英]Can you generate a Liquibase changelog XML file from SQL code?

I have some SQL scripts that I'd like to convert into Liquibase XML changelogs.我有一些 SQL 脚本,我想将它们转换为 Liquibase XML 变更日志。 Is this possible?这可能吗?

What exactly do you mean by "convert into changelogs"? “转换为变更日志”到底是什么意思?

If you don't need cross-database compatibility, you could just use the sql executor:如果您不需要跨数据库兼容性,则可以使用sql执行器:

<changeSet id="testing123" author="me">
  <sql splitStatements="false">
    <!-- all your existing SQL paste here -->
  </sql>
</changeSet>

The splitStatements=false setting will make sure the complete SQL will be sent in one command; splitStatements=false设置将确保完整的 SQL 将在一个命令中发送; otherwise, Liquibase would split it into multiple commands at semicolons.否则,Liquibase 会将其拆分为多个以分号分隔的命令。

You could use a detour via a database.您可以通过数据库使用绕行。 Apply your script to a database of choice (that is supported by liquibase).将您的脚本应用到选择的数据库(由 liquibase 支持)。 Then use generateChangeLog to generate the changelogs in xml from the database.然后使用generateChangeLog从数据库中生成 xml 中的更改日志。 You will have the XML changelog generated for all the SQL scripts you have applied to your database.您将为已应用于数据库的所有 SQL 脚本生成 XML 更改日志。

Alternatively, have a look at answer on this SO post .或者,看看这个 SO post上的答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Liquibase 随附 Spring Boot 使用 changelog.xml 很好地处理数据库。 它如何同时生成其 sql? - Liquibase coming with Spring Boot handles the database well with changelog.xml. How can it generate its sql at the same time? 使用liquibase为单个SQL文件生成changeLog - Generate changeLog for single sql files with liquibase liqubase:在没有数据库连接的情况下从changelog xml生成SQL脚本 - liqubase: generate sql script from changelog xml without db connection 有没有办法将 SQL 查询转换为 liquibase 更改日志格式? - Is there a way to convert SQL queries to liquibase changelog format? 向 liquibase 变更日志文件添加更多变更集的问题 - Issue adding more changesets to liquibase changelog file 从sql数据库生成站点地图XML文件? - Generate sitemap XML file from sql database? 如何将属性值动态传递给 liquibase 更改日志中的 sql 标记 - How to pass property value dynamically to sql tag in liquibase changelog 如何编写查询以从SQL Server表生成XML文件 - How to write query to generate XML file from SQL Server table 如何从 sql 服务器中的 XML 生成特定表? - How Can I generate specific table from XML in sql server? Liquibase 双向关系变更日志顺序 - Liquibase bidirectional relationships changelog order
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM