I've got the following setup in Windows Azure:
- A "test" hosted service connected to its own "test" database.
- A "production" hosted service connected to its own "production" database.
When a build has been verified on test and is ready to go to production, we spin up a "staging" deployment in the production hosted service, and do a quick smoke test to make sure the new build is not totally broken. The staging instance is deployed with the exact bits that will be deployed to production, so it's talking to the production database. When staging is blessed, we hit the "VIP Swap" button, and the build is live on production. All is good.
The problem comes about when the database model changes. I've got Code First Migrations working perfectly. I can add new migrations, apply them locally with the package manager console, and then generate SQL scripts to upgrade the test database when I push a new build to test. The question is, what's the best practice on using Code First Migrations along with staging/production deployments? When I deploy a new build to staging with model changes, it expects to find a database that matches its model. But then if I apply the model changes to the production database, the production instance complains because its model doesn't match.
I've just been skipping the staging smoke test. I upload to staging, then update the production database and hit the "VIP Swap" button pretty much at the same time. Then smoke test on production. If something is majorly broken, "Swap VIP" back and revert the database changes.
Is there a better way to do this, or is that pretty much it?
Thanks!