Are there recommended procedures for migrating database schema upgrades from development to production database servers?
I'm almost done writing a web app that uses NHibernate through a class library I've written. I know that shortly after release of the first version, I'll be changing the db schema some more to add features and such. The changes will likely include added, moved and removed columns, changed column datatypes, and new tables.
So far in development, when I change a mapping file, I just have NHibernate tear down and rebuild the whole database, and I have code to fill the db with some initial data I use for development. But how can I safely merge these schema changes into production to minimize lost data and time?
I'm hoping that there's a best practices list or something. The two ways that strike me are:
1. Write a routine that loads every single object from the database into memory (using NHibernate), then rebuild the database, then persist every object back again.
2. Go through the database structure myself (using SQL Enterprise Manager in my case) and actually add the tables, change the datatypes, etc. that were done automatically for me in the dev db. The problem I see with this is NHibernate seems to have finer control over datatypes than what SQL Enterprise Manager lets me see. For example, the varbinary datatype may appear to have one length, but if I reproduce it in another db, NHibernate somehow recognizes that it is not the original, and crashes until I let NHibernate rebuild it.
Can anyone with experience or good ideas share them?