Skip to content

Creating Rock Migrations

nairdo edited this page Feb 21, 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.

Create the new migration class

  1. Run the Dev Tools\Sql\CodeGen_PagesBlocksAttributesMigration.sql script. It will output stuff you'll want to use in your next step.
  2. Run AddMigration [YOUR_MIGRATION_NAME]
  3. 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 the Down() method.
  4. REVIEW each item you just pasted. Not all of them are things you should include in your migration.

Test your new migration class

  1. Replace your db name with a new database name into your RockContext connection string in your web.connectionStrings.config file.
  2. Run Update-Database to see if it worked
  3. Verify everything by running Rock (F5) and checking every detail of your stuff.
  4. If it's not good return to step 3 in the previous section; otherwise proceed to Commit/Push/Deploy

Commit/Push/Deploy

If everything looks good, you can commit your changes, merge (as needed) and push up to origin.

Clone this wiki locally