Liquibase generateChangeLog命令

编程入门 行业动态 更新时间:2024-10-24 23:22:41
Liquibase generateChangeLog命令 - 使用insert语句生成changelog(Liquibase generateChangeLog command - generating changelog with insert statements)

要从我的数据库(oracle,db2)生成插入语句,我使用了liquibase generateChangeLog命令和参数

--diffTypes = “数据”

此命令使用insert语句生成正确的xml,但是这不知道外部约束,因此我不能再使用此文件来填充我的数据库。 这里已经描述了类似的问题: 有没有办法以正确的顺序生成Liquibase数据? 。 不幸的是,我提出的解决方法对我的数据库来说是不可能的,因为没有任何命令来切换约束检查。

我的问题是,如果存在这个问题的任何其他解决方案? 为什么我可以生成数据插入语句changelog,但由于外键约束而无法使用它?

To generate insert statements from my databases (oracle,db2) i've used liquibase generateChangeLog command with argument

--diffTypes="data"

This command generate correct xml with insert statements, however this is not aware of foreign constraints, so I cannot use this file to again to fill my databases. Similar problems has been described here : Is there a way to generate Liquibase data in the right order?. The proposed workaround unfortunatelly is not possibile for my databases, because there is no any command to switch of constraint checks.

My question is, if exists any other solution to this problem ? Why can I generate data insert statements changelog, but cannot use it because of foreign key constraints ?

最满意答案

Jens在评论中是正确的。 Liquibase无法确定依赖关系,因为主要用例是跟踪运行changeSet。 GenerateChangeLog是一个有用的功能,但它并不打算处理所有情况,管理依赖项是一项复杂的任务,绝对超出了范围。

我的正常建议是,generateChangeLog的输出应该被认为是使用changeLog的有用的第一步,如果你有依赖性问题,只需在执行它们之前重新排序changeSet。 如果有很多,您可能需要编写一个脚本,根据您对依赖项的了解对它们进行重新排序。

Jens is right in the comment. Liquibase has no way of determining dependencies because the main use case is tracking ran changeSets. GenerateChangeLog is a useful capability but it is not intended to handle all cases and managing dependencies is a complex task that is definitely out of scope.

My normal recommendation is that the output of generateChangeLog should be considered a useful first step for working with the changeLog and if you have dependency issues just reorder the changeSets before executing them. If there many of them, you may want to write a script to reorder them based on your knowledge of your dependencies.

更多推荐

本文发布于:2023-07-29 14:11:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1316782.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:命令   Liquibase   generateChangeLog

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!