Liquibase Changeet:如何根据另一个表构建子句
基于问题 liquibase更改,我想根据来自其他表格的列的值选择列的默认值。
例如,我有两个表格, order 和 order_history 。请注意,我们也将所有订单都保持在 order order_history 中。订单完成后,将其从订单表中删除。
order 具有“状态”列,但我们在 order_history 上错过了它,您可以称其为不良设计。 我现在如何将“状态”添加到 order_history 现在,然后从相应的顺序复制值 在升级时在顺序表中用于现有数据?有没有办法在Liquibase中做到这一点?
Building upon the question How to build a WHERE-clause in a LiquiBase changeset, I would like to choose the default value of a column based on the value of a column from a different table.
For instance, I have two tables, order and order_history. Pls note that we maintain all our orders in both order in order_history as well. Once an order is completed, it is removed from order table.
order has a column 'status' but we missed it on order_history, you can call it a bad design.
How do I add 'status' to order_history now, and copy the value from the corresponding order
in order table for existing data at the time of upgrade? Is there a way to do this in liquibase?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果
order
和order_history
与外键连接,则可以执行以下操作:如果这些表未连接,则可以使用
defaultValueComputed 添加新列时:
If
order
andorder_history
are connected with the foreign key, then you can just do the following:If these tables are not connected, then you may use
defaultValueComputed
when you're adding a new column: