Developer Codex

Process to Chop or Swap

The RockMigrationHelper.ReplaceWebformsWithObsidianBlockMigration(…) helper will create a job that performs either a chop or swap of a block type. This helper method will create a Rock.Jobs.PostUpdateDataMigrationsReplaceWebFormsBlocksWithObsidianBlocks job that performs the chop/swap. It is used like this:

RockMigrationHelper.ReplaceWebformsWithObsidianBlockMigration(
    "Chop <or Swap> <Description of item(s) being chopped/swapped>",
    blockTypeReplacements: new Dictionary<string, string> {
        { "ABC123-1111-1111-1111-111111111111", "DEF456-2222-2222-2222-222222222222" }
    },
    migrationStrategy: "Chop", // or "Swap"
    jobGuid: "<New GUID of Job Instance that will run to execute the chop>"  );

Where the first Guid (ABC123-…) is the block type of the original block being replaced and the second Guid (DEF456-…) is the new block type to replace the original with.

When you are ready to chop/swap your Obsidian block follow these steps:

  1. Backup your local database
  2. Test locally by simply adding a throw-away Rock\Plugin\HotFixes\###_TEMP_TEST_CHOP-or-SWAP.cs
  3. Start Rock and then manually run the job that got created
    1. Verify that the original block instances were replaced with the new block type and the block settings were all copied over.
    2. (if chop) Verify that the old block type files and [BlockType] record were deleted.
  4. If successful…
    1. Create a sub-task in your conversion task called "Chop: <block type name>"
    2. Put the contents of your ReplaceWebformsWithObsidianBlockMigration(..)into the description field.
    3. Copy the link to that sub-task and paste it into the v17 Chop: Merge Sets of Obsidian Blocks to develop and Chop Migration (v17)
    4. Restore your database (for cleanup purposes).
  5. Later, when the Pre-Alpha Release is packaged, the packager will:
    1. Move your old/new block type Guids with all the others into new post-update (See Post Update / Run Once Job) ReplaceWebformsWithObsidianBlockMigration data migration job.
    2. Add the job to the Rock.Migrations.RockStartup.DataMigrationStartup.OnStartup() method.
    3. Run the job and (if chop) verify the files were deleted.
    4. (if chop) The packager will commit the deletion of those files since they are now considered 'chopped'. (Note: these files will not be added to the official release package's deletefile.lstso that they are not prematurely deleted upon update but instead will be deleted by the post-update job.