liquibase 可以用来管理双向变化吗?

Can liquibase be used to manage two-way changes?

我是 liquibase 的新手,想看看这是否是处理此问题的理想工具。如果合适,请也推荐 liquibase 之外的其他人。

用例:

我们有一个用户可以修改的 属性 文件。我们正在寻找利用 liquibase 来维护用户更改和新更改的解决方案。 liquibase 可以吗?工作流程会是什么样子?

// Version 1; Release 1
<a>
<b foo="1"></b>
<a>

现在,我们推出版本 1,客户 A 已将 foo 修改为 2 以达到他们的目的;这就是客户 A 进行更改后版本 1 现在的版本。客户端 B 没有做任何更改。

// Version 1; Release 1 - at client A
<a>
<b foo="2"></b>
<a>
// Version 1; Release 1 - at client B
<a>
<b foo="1"></b>
<a>

现在在第 2 版中,我们将 foo 更新为 10,并添加了一个新变量 'goo'。 所以,这就是版本 1 的增强方式

// Version 2; Release 2
<a>
<b foo="10" goo="2"></b>
<a>

现在,当我们将客户端升级到版本 2 时,我们希望客户端在更改时保持 foo 的值,否则将其切换到 10。还需要添加 'goo'。

因此,升级后,客户端文件应如下所示:

// Version 2; Release 2 - at client A
<a>
<b foo="2" goo="2"></b>
<a>
// Version 2; Release 2 - at client B
<a>
<b foo="10" goo="2"></b>
<a>

======================

我们考虑的解决方案是将此 xml 保存到 table 中,并使用 liquibase 对其进行版本化。 在升级客户端 B 之前,将它们的 xml 转储到 liquibase,并以某种方式发现它与安装的不同。 现在,使用一些差异,启用上述结果。

需要一些想法吗? TIA!

使用 PreCondition 会起作用 - 只要您只有少量更改,它就可以检测用户更改而不会太复杂,即您所描述的边缘情况。如果它变得更复杂,您可能需要不同的解决方案或者可能需要编写自定义前提条件以适应增加的复杂性。文档:https://docs.liquibase.com/concepts/changelogs/preconditions.html

我还发现了另一个问题,看起来可能与您的问题类似。 Link: Can Liquibase handle multiple schemas managed by the same application?

来自 Liquibase 的 Nathan Voxland 的回答 co-founder:

Liquibase can handle objects within multiple schemas and can also manage creating additional schemas as well.

When you connect to the database, Liquibase will create a DATABASECHANGELOG table in the default schema and that schema needs to exist. That table tracks which changeSets have executed, and anything that can be done through SQL can be done within your changeSets.

There are built-in tags for things like createTable, addColumn etc which will make changes in the default schema, but they all have tags such as tableSchemaName that can be used to target the object to a different schema.

If you want to make changes for which there are not built-in tags, you can always use the "sql" tag and specify whatever sql you want, such as create database additional_info