开发者

Liquibase - Rolling back a set of changesets

We do database releases which are made up of a group of change sets and our database change logs are organised in the following way

   M开发者_如何学PythonasterChangeLog.xml

           ---> Release0001.XML
                    ---> AddCustomerTable.XML
                    ---> AddOrderTable.XML

           ---> Release0002.XML
                    ---> AddNewColumnsToCustomerTable.XML
                    ---> AlterOrderTableXML

           ---> Release0003.XML
                    ---> AddPreferedCustomerTable.XML

I would like to know how I would go about rolling back a set of change sets. I was hoping that I could use tagDatabase with the release number (Release001, Release002 or Release003) and just roll back using the tag

I would expect to be able to do something like this if I wanted to rollback all change to Release001

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

Could you please tell me how I would go about getting this to work with Liquibase?

Thanks


The command you listed is valid if Release002 is a valid tag. You probably don't want/need quotes around the Release0002 tag, though.

When rolling back using a tag, liquibase will start at the end of your executed changesets and roll back each in reverse order until it gets to the changeset that was tagged before. I am not sure from your description if that is what you want.

In your example, if you tagged the database after Realease002.xml ran, running "rollback Release0002" would roll back everything in Release0003. If you wanted to rollback everything in Release0002 you would need to run "rollback Release0001" or make the Release0002 tag before executing the Release0002 changesets. Either way, however, you will have Release0003 rolled back because it came after Release0002.

The reason liquibase does not support picking and choosing changeSets to roll back is because there is often dependencies between changesets because they often build upon each other, and so rolling back an arbitrary group of changesets in the middle often has unexpected consequences.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜