wederer
wederer

Reputation: 570

Liquibase execution order of changes inside of changeSet

We are using liquibase to split a column into two columns. This happens in three changes:

  1. Add the new columns via addColumn
  2. Insert the data from the old column into the new ones via a customChange
  3. Delete the old column via dropColumn

This works great, but I can not find any documentation on the order of execution of changes. I only found documentation on the order of execution of changeSets, see here.

Does liquibase guarantee, that the changes are executed sequentially in the order that they appear?

Upvotes: 4

Views: 2818

Answers (1)

htshame
htshame

Reputation: 7330

I've never saw any documentation about it, but in my experience - it does execute changes inside the changeSet sequentially in the order they appear.

Also, I don't think it's good practice to put all the above changes into one changeSet, because, as stated in the document you've provided:

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.

I suggest separating your changeSet into three atomic ones with appropriate preConditions, or create a proper rollback for it.

Upvotes: 4

Related Questions