forked from SparkDevNetwork/Rock
-
Notifications
You must be signed in to change notification settings - Fork 12
Creating Rock Migrations
nairdo edited this page Feb 22, 2013
·
10 revisions
When your code is ready to check in and you're ready to include it in the database as well, here's a checklist to review and use.
- Run the
Dev Tools\Sql\CodeGen_PagesBlocksAttributesMigration.sqlscript. It will output stuff you'll want to use in your next step. - Run
AddMigration [YOUR_MIGRATION_NAME] - Edit this skeleton migration and paste in the stuff from the MigrationUp output into your migration's
Up()method and then the MigrationDown output into theDown()method. Pay particular attention to the order that things are deleted since you cannot delete many things unless any related items are first deleted. - REVIEW each item you just pasted. Not all of them are things you should include in your migration.
- Manually add any other data items that were not already accounted for by the SQL script including:
- EntityTypes
- NoteTypes
- PageContext (if any of your blocks use Context you should double-check this one)
- Replace your db name with a new database name into your RockContext connection string in your
web.connectionStrings.configfile. - Run Update-Database to see if it worked
- Verify everything by running Rock (F5) and checking every detail of your stuff.
- If it's not good return to step 3 in the previous section; otherwise proceed to next step.
- Lastly, test your
Down()migration by migrating back to the last migration that exists before your new migration. Use theUpdate-Database TargetMigration:[THE_PREVIOUS_ONE]. If that was successful, continue to the Commit/Push/Deploy section otherwise go back to step 3 in the previous section.
If everything looks good, you can commit your changes, merge (as needed) and push up to origin.