Liquibase - rollback a set of changesets

We release databases that consist of a group of change sets, and our database change logs are organized as follows.

MasterChangeLog.xml ---> Release0001.XML ---> AddCustomerTable.XML ---> AddOrderTable.XML ---> Release0002.XML ---> AddNewColumnsToCustomerTable.XML ---> AlterOrderTableXML ---> Release0003.XML ---> AddPreferedCustomerTable.XML 

I would like to know how I was going to collapse a set of change sets. I was hoping I could use tagDatabase with the release number (Release001, Release002 or Release003) and just rollback using the tag

I would expect that I could do something like this if I want to undo all the changes before Release001

 java -jar "liquibase.jar" --changeLogFile="MasterChangeLog.xml" Rollback "Release0002" 

Could you tell me how I am going to get this to work with Liquibase?

thanks

+7
liquibase
source share
1 answer

The command you select is valid if Release002 is a valid tag. You probably don't want / need quotes in the Release0002 tag.

When rolling back using the tag, Liquibase will begin at the end of the completed change sets and roll back each in the reverse order until it falls into the change set that was previously marked. I am not sure about your description if that is what you want.

In your example, if you marked the database after running Realease002.xml, running "rollback Release0002" will drop everything in Release0003. If you want to roll back everything in Release0002, you will need to run "rollback Release0001" or make the Release0002 tag before executing Release0002 change sets. In any case, you will have Release0003 rolled back, because it appeared after Release0002.

The reason Liquibase does not support selection, and choosing changeSets for rollback, is because dependencies often depend on changesets, because they often overlap, and therefore rolling back an arbitrary group of changesets in the middle often leads to unexpected consequences.

+8
source share

All Articles