[英]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.