changeSet 内部变更的 Liquibase 执行顺序

Liquibase execution order of changes inside of changeSet

我们正在使用 liquibase 将一列拆分为两列。这发生在三个变化中:

  1. 通过 addColumn
  2. 添加新列
  3. 通过 customChange
  4. 将旧列中的数据插入到新列中
  5. 通过dropColumn
  6. 删除旧列

效果很好,但我找不到任何关于 changes 执行顺序的文档。 我只找到了关于 changeSets 执行顺序的文档,参见 here.

liquibase 是否保证更改按出现的顺序依次执行?

我从未见过任何关于它的文档,但根据我的经验 - 它确实按照它们出现的顺序在 changeSet 中顺序执行更改。

此外,我认为将上述所有更改合并为一个 changeSet 并不是一个好的做法,因为,正如您提供的文档中所述:

Liquibase attempts to execute each changeSet in a transaction that is committed at the end, or rolled back if there is an error. Some databases will auto-commit statements which interferes with this transaction setup and could lead to an unexpected database state. Therefore, it is usually best to have just one change per changeSet unless there is a group of non-auto-committing changes that you want applied as a transaction such as inserting data.

我建议用适当的 preConditions 将你的 changeSet 分成三个原子的,或者为它创建一个合适的 rollback