All of our database scripts go through several stages of testing with databases that are similar to our database. Thus, we can be fairly confident that the modification scripts will work as expected.
For rollback, stored procedures, views, functions, triggers, all software, rollback is easy, just apply the previous version of the object.
As you mentioned, the hard part comes up when updating / deleting records from tables or even when adding new columns to tables. And you are right that in this case, a rollback can be as likely as a failure.
We do this if we have changes that cannot be easily discarded, but this is a sensitive / critical section ... is that we have dialback rollback scripts that also go through the same test environments. We run the script update, verify that it is working properly, and then run the script rollbacks and verify that it works as it was before the change.
Another thing we do as a precaution is to take a database snapshot (SQL Server 2005) before upgrading. Thus, if there are any unexpected problems, we can use the snapshot to recover any data that was potentially lost during the update.
Thus, the safest way to do this is to test the databases as close as possible to your live system, and also check your rollback scripts ... and just in case both of them fail, if necessary.
source share