What is the best way to handle database upgrades?
Currently we run an upgrade script that does stuff like:
If column does not exist then
add column.
Is there a better way? This script is a giant?
This question is in regards to Microsoft and SQL server 2005/2008
If this is deployed to many different locations, then what you have is exactly how to do it. Or you can use something like Red Gate’s SQL Packager
If this is a question on how to deploy to just a few locations, for example moving from staging to production, then use Red Gate’s SQL Compare and/or SQL Data Compare products.
FYI – I do not work for Red Gate; I just really like their stuff.
I’ve tried using Microsoft’s tools for schema and data comparisons. The data tool works just fine; the schema tool is over engineered and difficult thing to get to work right. Quite frankly I’ve seen MS’s schema tool screw up enough updates that I flat don’t trust it anymore.
One of the many drawbacks to MS’s tool is that by default it wants to update things like the physical location of the files on the server. This presents problems when you have multiple copies of the database on the same server. I don’t think they thought the development of this tool out very well. The UI is difficult to work with as well.