Question

I want to migrate my database from v1.0 to v1.1 and one of the changes is updates on some of the values in Table1. I know that for INSERT, I can easily include a rollback command of deleting the values I just added, but how about a table alteration? Is there a way to store the current value and use this information for the rollback process (in the future)?

Thanks.

Was it helpful?

Solution

You can specify a <rollback> block (docs) in your changeset to describe how to roll back the change. Within your rollback tag you can use raw SQL or a <createTable> tag to re-describe what the table looked like before it was altered.

You can also specify the changeSetId and changeSetAuthor in the rollback tag to point to an existing changeSet that will recreate the table. This approach can be easier if there has been no other changes since the object was created but doesn't work as well if there has been multiple changeSets that modified the object since it was first created.

OTHER TIPS

Any DDL operation (ALTER TABLE being one of them) in SQL Server is transactional.

It means that you can open a transaction, do alterations to the database objects, and rollback the transaction as if it never happened.

There are some exceptions, mainly actions involving filesystem operations (adding a file to database and such).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top