要从我的数据库(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.
更多推荐
发布评论