简体   繁体   English

使用liquibase迁移数据

[英]using liquibase to migrate data

We have two identical database (say A and B), and wonder if its possible to use liquibase to migrate selective data from A to B. 我们有两个相同的数据库(例如A和B),想知道是否有可能使用liquibase将选择性数据从A迁移到B。

A is a read/write database and B is read-only. A是读/写数据库,B是只读的。 We have written a system where users make changes to A and then 'copy' only selective changes made to B. 我们编写了一个系统,其中用户对A进行更改,然后仅“复制”对B所做的选择性更改。

I was wondering if it was possible/good idea to use liquibase to do this. 我想知道是否可以使用liquibase做到这一点。

The idea is to either; 这个想法要么是;要么是。

  1. Insert new records in B if they don't exist and Update records if they do 如果不存在,则在B中插入新记录;如果不存在,则将其更新
  2. Delete all the data in all the tables in B and repopulate them with the ones from A 删除B中所有表中的所有数据,并使用A中的表重新填充它们

We already use liquibase to manage database changes to our database structure. 我们已经使用liquibase来管理数据库对数据库结构的更改。

Thanks, Jack. 谢谢,杰克。

No, it is not what Liquibase is designed for. 不,这不是Liquibase设计的目的。 Liquibase's primary function is to make sure that changeSets defined in the changelog file are ran against a given database. Liquibase的主要功能是确保针对指定数据库运行changelog文件中定义的changeSet。 Those changeSets can be data changes or schema changes, but they need to be defined in the changelog file. 这些changeSet可以是数据更改或架构更改,但是需要在changelog文件中定义它们。

Liquibase does have some diff features, but they are secondary functionality and make no attempt at comparing data beyond populating all data from a table. Liquibase确实具有一些差异功能,但它们是辅助功能,除了填充表中的所有数据外,不尝试比较数据。

Since the copy process is selective, it sounds like there needs to be some level of UI and/or business logic around it in your application and including the actual copy logic in your application probably makes the most sense. 由于复制过程是选择性的,因此听起来您的应用程序中需要围绕它进行某种级别的UI和/或业务逻辑,并且在您的应用程序中包含实际的复制逻辑可能是最有意义的。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM