-
Notifications
You must be signed in to change notification settings - Fork 247
RoundhousEModes
RoundhousE has three modes which can be combined to create interesting work flows. Here are the modes:
- Normal: Runs all necessary scripts. It will even create the database if necessary.
- DropCreate: Drops the existing database and then executes Normal mode.
- RestoreRun: Restores a backup (the baseline) into the existing database and then executes in Normal mode.
These are actually workflows. In a Normal mode/workflow, you just execute RH without restore configured. In RestoreRun mode, you execute RH with restore options configured. The one that seems to trip up most new people is understanding DropCreate mode, but it's simply a run that has /drop
specified followed by a normal run.
If you are developing an application that has not yet made it into production, you will want to run in DropCreate mode. This will drop and re-create your database each time you run RH. Be sure to include scripts that insert any reference data your application requires. This mode ensures your deployments are tested in the same manner they will be executed the day you push the application to production.
Once your application has been deployed to production, you will want to take advantage of the RoundhousE's two other modes: Normal and RestoreRun.
You will want to fully exercise your database deployment process through development, QA and staging. By the time you've made it through the deployment pipeline, you want to be confident that your scripts will work correctly against the database version already in production. The best way to do accomplish this is running RoundhousE in RestoreRun mode:
- Take a backup of your production database[1] and put it on a network share. This will be the baseline for development, QA and Staging deployments.
- When deploying releases to each of these environments, execute RoundhousE using RestoreRun mode and point it at the baseline created in step 1. In this mode, RoundehousE will restore the target database from the production database backup and then apply new migration scripts.
Deployments to production should be done using Normal mode. RoundhousE will simply run the necessary scripts to bring the production database up to date. After the new version has gone live, take a new backup from production and use this as your new baseline for deploying throughout the deployment pipeline.
[1] Using a true production backup may be hard for large databases or databases with sensitive data. You are simply trying to gain confidence that the scripts you are going to run on production will work as expected, so if you can't use a replica of your production database, perhaps try with a copy of a staging area that is somewhat representative of the data you typically find in production.