Ejemplo n.º 1
0
        private void AddCheckinByGender()
        {
            RockMigrationHelper.UpdateFieldType("Gender", "Used to select a gender", "Rock", "Rock.Field.Types.GenderFieldType", "2E28779B-4C76-4142-AE8D-49EA31DDB503");

            RockMigrationHelper.AddGroupTypeGroupAttribute("0572A5FE-20A4-4BF1-95CD-C71DB5281392", "2E28779B-4C76-4142-AE8D-49EA31DDB503", "Gender", "The gender allowed to check in to these group types.", 2, "", "DE6F800F-0177-4DAE-BA9B-AD75F20F255B");
            Sql(@"
    -- Make sure the attribute belongs to the 'Check-in' cateogry
    DECLARE @GroupTypeEntityTypeId int = ( SELECT TOP 1 [Id] FROM [EntityType] WHERE [Name] = 'Rock.Model.GroupType' )
    DECLARE @AttributeEntityTypeId int = ( SELECT TOP 1 [Id] FROM [EntityType] WHERE [Name] = 'Rock.Model.Attribute' )
    DECLARE @AttributeId int = ( SELECT TOP 1 [Id] FROM [Attribute] WHERE [Guid] = 'DE6F800F-0177-4DAE-BA9B-AD75F20F255B' )
    DECLARE @CategoryId int = ( SELECT TOP 1 [Id] FROM [Category] WHERE [Name] = 'Check-in' AND [EntityTypeId] = @AttributeEntityTypeId AND [EntityTypeQualifierColumn] = 'EntityTypeId' AND [EntityTypeQualifierValue] = CAST( @GroupTypeEntityTypeId AS varchar) )
    DELETE [AttributeCategory] WHERE [AttributeId] = @AttributeId AND [CategoryId] = @CategoryId
    INSERT INTO [AttributeCategory] ( [AttributeId], [CategoryId] ) VALUES ( @AttributeId, @CategoryId )
");

            RockMigrationHelper.UpdateEntityType("Rock.Workflow.Action.CheckIn.FilterGroupsByGender", "B16E3329-49F4-4DA0-9802-E7BA75F5FD42", false, true);
            RockMigrationHelper.UpdateWorkflowActionEntityAttribute("B16E3329-49F4-4DA0-9802-E7BA75F5FD42", "1EDAFDED-DFE6-4334-B019-6EECBA89E05A", "Active", "Active", "Should Service be used?", 0, @"False", "6EC3B2A5-E962-476F-8052-B795AE2ECEF3");
            RockMigrationHelper.UpdateWorkflowActionEntityAttribute("B16E3329-49F4-4DA0-9802-E7BA75F5FD42", "A75DFC58-7A1B-4799-BF31-451B2BBE38FF", "Order", "Order", "The order that this service should be used (priority)", 0, @"", "81957147-9C2D-424E-A9B7-386A72937892");
            RockMigrationHelper.UpdateWorkflowActionEntityAttribute("B16E3329-49F4-4DA0-9802-E7BA75F5FD42", "1EDAFDED-DFE6-4334-B019-6EECBA89E05A", "Remove", "Remove", "Select 'Yes' if groups should be be removed.  Select 'No' if they should just be marked as excluded.", 0, @"True", "1E1F7819-D6EA-4F0B-B30B-90429BDA9808");

            RockMigrationHelper.UpdateWorkflowActionType("EB744DF1-E454-482C-B111-80A54EF8A674", "Filter Groups by Gender", 0, "B16E3329-49F4-4DA0-9802-E7BA75F5FD42", true, false, "", "66EF6CB1-1A96-2F81-4534-3BCA5C33D4CD", 1, "False", "EDDD1612-DFE4-4538-84E2-BCC8E869A2F3");

            Sql(@"
    -- Fix the ordering of the Person Search workflow activity so that the 'Filter By Gender' activity is immediately after 'Filter By Grade'
    DECLARE @ActivityTypeId int = ( SELECT TOP 1 [Id] FROM [WorkflowActivityType] WHERE [Guid] = 'EB744DF1-E454-482C-B111-80A54EF8A674' )
    DECLARE @EntityTypeId int = ( SELECT TOP 1 [Id] FROM [EntityType] WHERE [Name] = 'Rock.Workflow.Action.CheckIn.FilterGroupsByGrade' )
    DECLARE @Order int = ISNULL( ( SELECT TOP 1 [Order] FROM [WorkflowActionType] WHERE [ActivityTypeId] = @ActivityTypeId AND [EntityTypeId] = @EntityTypeId ), 0)
    IF @Order IS NOT NULL AND @Order > 0
    BEGIN
        UPDATE [WorkflowActionType] SET [Order] = [Order] + 1 WHERE [ActivityTypeId] = @ActivityTypeId AND [Order] > @Order
        UPDATE [WorkflowActionType] SET [Order] = @Order + 1 WHERE [Guid] = 'EDDD1612-DFE4-4538-84E2-BCC8E869A2F3'
    END
");
        }
        /// <summary>
        /// Operations to be performed during the upgrade process.
        /// </summary>
        public override void Up()
        {
            RockMigrationHelper.AddGroupType("Check in by Data View", "", "Group", "Member", false, false, false, "", 0, "", 0, "6BCED84C-69AD-4F5A-9197-5C0F9C02DD34", "DC7ED2FD-5F88-4760-B3C8-494EDB1CFC06", true);
            RockMigrationHelper.AddGroupTypeGroupAttribute("DC7ED2FD-5F88-4760-B3C8-494EDB1CFC06", SystemGuid.FieldType.DATAVIEWS, "Data View", "The data view a person must be included in to be able to check into this group.", 0, "", "E8F8498F-5C51-4216-AC81-875349D6C2D0");
            RockMigrationHelper.AddAttributeQualifier("E8F8498F-5C51-4216-AC81-875349D6C2D0", "entityTypeName", "Rock.Model.Person", "D59BAD04-4C23-497C-810A-328B760B7C6B");

            RockMigrationHelper.UpdateEntityType("Rock.Workflow.Action.CheckIn.FilterGroupsByDataView", "E6490F9B-21C6-4D0F-AD15-9729AC22C094", false, true);
            RockMigrationHelper.UpdateWorkflowActionEntityAttribute("E6490F9B-21C6-4D0F-AD15-9729AC22C094", "1EDAFDED-DFE6-4334-B019-6EECBA89E05A", "Active", "Active", "Should Service be used?", 0, @"False", "0B1FF2A0-D0CE-42A5-95BC-C65F02D14399");
            RockMigrationHelper.UpdateWorkflowActionEntityAttribute("E6490F9B-21C6-4D0F-AD15-9729AC22C094", "A75DFC58-7A1B-4799-BF31-451B2BBE38FF", "Order", "Order", "The order that this service should be used (priority)", 0, @"", "869473D0-AC93-4F8F-B164-2A332571E779");
            RockMigrationHelper.UpdateWorkflowActionEntityAttribute("E6490F9B-21C6-4D0F-AD15-9729AC22C094", "1EDAFDED-DFE6-4334-B019-6EECBA89E05A", "Remove", "Remove", "Select 'Yes' if groups should be removed.  Select 'No' if they should just be marked as excluded.", 0, @"True", "5EE8CC8E-455D-4115-88F4-81D224A30A28");

            RockMigrationHelper.UpdateWorkflowActionType("EB744DF1-E454-482C-B111-80A54EF8A674", "Filter Groups by DataView", 0, "E6490F9B-21C6-4D0F-AD15-9729AC22C094", true, false, "", "66EF6CB1-1A96-2F81-4534-3BCA5C33D4CD", 1, "False", "31F407AA-50BB-4915-BB22-7AF463989D98");

            Sql(@"
    -- Fix the ordering of the Unattended Check-in Id: 10 workflow activity so that the 'Filter By Data View' activity is immediately after 'Filter By Gender'
    DECLARE @ActivityTypeId int = ( SELECT TOP 1 [Id] FROM [WorkflowActivityType] WHERE [Guid] = 'EB744DF1-E454-482C-B111-80A54EF8A674' )
    DECLARE @EntityTypeId int = ( SELECT TOP 1 [Id] FROM [EntityType] WHERE [Name] = 'Rock.Workflow.Action.CheckIn.FilterGroupsByGender' )
    DECLARE @Order int = ISNULL( ( SELECT TOP 1 [Order] FROM [WorkflowActionType] WHERE [ActivityTypeId] = @ActivityTypeId AND [EntityTypeId] = @EntityTypeId ), 0)
    IF @Order IS NOT NULL AND @Order > 0
    BEGIN
        UPDATE [WorkflowActionType] SET [Order] = [Order] + 1 WHERE [ActivityTypeId] = @ActivityTypeId AND [Order] > @Order
        UPDATE [WorkflowActionType] SET [Order] = @Order + 1 WHERE [Guid] = '31F407AA-50BB-4915-BB22-7AF463989D98'
    END
");
        }
Ejemplo n.º 3
0
        public override void Up()
        {
            //Childrens checkin base
            RockMigrationHelper.AddGroupType("Children Check-In", "Base checkin group for all of check-in.", "Group", "Member", false, false, false,
                                             "", 100, Constants.GROUP_TYPE_BY_BASE, 0, Rock.SystemGuid.DefinedValue.GROUPTYPE_PURPOSE_CHECKIN_FILTER, Constants.GROUP_TYPE_BY_CHILDREN_CHECKIN_BASE);
            RockMigrationHelper.AddGroupTypeGroupAttribute("5398A1C2-F422-4ADC-A48B-B9EFFE3598AD", "1EDAFDED-DFE6-4334-B019-6EECBA89E05A", "Link Locations", @"Should all all locations for this group be required to be the same?", 0, "False", "0A8723A4-4AEE-4D21-A32B-350845FC8FA9", "");
            RockMigrationHelper.AddGroupTypeGroupAttribute("5398A1C2-F422-4ADC-A48B-B9EFFE3598AD", "1EDAFDED-DFE6-4334-B019-6EECBA89E05A", "Is Volunteer", @"Do people checking into this group count as volunteers?", 1, "", "F5DAD320-B77D-4282-98C9-35414FB0A6DC", "");
            RockMigrationHelper.AddGroupTypeGroupAttribute("5398A1C2-F422-4ADC-A48B-B9EFFE3598AD", "1EDAFDED-DFE6-4334-B019-6EECBA89E05A", "Give Priority", @"", 2, "False", "DABEABAC-F052-471B-AC61-A7630465888B", "");

            //Checkin by Birthday
            RockMigrationHelper.AddGroupType("Check in by Birthday", "Checkin filter using birthdays.", "Group", "Member", false, false, false,
                                             "", 101, Constants.GROUP_TYPE_BY_CHILDREN_CHECKIN_BASE, 0, Rock.SystemGuid.DefinedValue.GROUPTYPE_PURPOSE_CHECKIN_FILTER, Constants.GROUP_TYPE_BY_BIRTHDAY);
            RockMigrationHelper.AddGroupTypeGroupAttribute("3600C17B-1D92-4929-B7B7-BBC156F2D47A", "9C7D431C-875C-4792-9E76-93F3A32BB850", "Date Range", @"", 0, "", "DABCC6EA-29EE-41EA-83DC-C2DF0065631D", "");
            RockMigrationHelper.AddGroupTypeGroupAttribute("3600C17B-1D92-4929-B7B7-BBC156F2D47A", "1EDAFDED-DFE6-4334-B019-6EECBA89E05A", "Filter GradeSchool Students", @"", 1, "", "8919515B-D654-43AA-A429-91A2B8A092CF", "");


            //Checkin by Membership
            RockMigrationHelper.AddGroupType("Check in by Membership", "Checkin filter using group membership.", "Group", "Member", false, false, false,
                                             "", 102, Constants.GROUP_TYPE_BY_CHILDREN_CHECKIN_BASE, 0, Rock.SystemGuid.DefinedValue.GROUPTYPE_PURPOSE_CHECKIN_FILTER, Constants.GROUP_TYPE_BY_MEMBERSHIP);
            RockMigrationHelper.AddGroupTypeGroupAttribute("2098AE58-58D4-4CEF-8D40-C2657D2E7A6A", "F4399CEF-827B-48B2-A735-F7806FCFE8E8", "Group", @"", 0, null, "22C7D86E-ABEA-4DFB-A83C-FC18100C9834", "");
            RockMigrationHelper.AddGroupTypeGroupAttribute(Constants.GROUP_TYPE_BY_MEMBERSHIP, Rock.SystemGuid.FieldType.SINGLE_SELECT, "Check Requirements",
                                                           "Should the requirements of the group be checked before allowing check-in. This is slower but needed in some situations.",
                                                           5, "0", Constants.GROUP_ATTRIBUTE_CHECK_REQUIREMENTS, false);
            RockMigrationHelper.AddAttributeQualifier(Constants.GROUP_ATTRIBUTE_CHECK_REQUIREMENTS, "values", "0^Do Not Check,1^Check Required Only,2^Check Required and Warning", "9E659023-6860-4872-B7C9-EB019FF76145");
            RockMigrationHelper.AddGroupTypeGroupAttribute(Constants.GROUP_TYPE_BY_MEMBERSHIP, Rock.SystemGuid.FieldType.SINGLE_SELECT, "Member Role",
                                                           "Optional filter to only allow people if they are a member or leader.",
                                                           6, "0", Constants.GROUP_ATTRIBUTE_MEMBER_ROLE, false);
            RockMigrationHelper.AddAttributeQualifier(Constants.GROUP_ATTRIBUTE_MEMBER_ROLE, "values", "0^Any,1^Leaders Only,2^Non Leaders Only", "840B04D7-DC1B-452B-A869-0AEB4904DC26");
            RockMigrationHelper.AddGroupTypeGroupAttribute(Constants.GROUP_TYPE_BY_MEMBERSHIP, Rock.SystemGuid.FieldType.BOOLEAN, "Save Attendance To Group",
                                                           "If selected, the attendance will be set on the group the person is a member of instead of on the check-in group.",
                                                           7, "False", Constants.GROUP_ATTRIBUTE_ATTENDANCE_ON_GROUP);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Operations to be performed during the upgrade process.
        /// </summary>
        public override void Up()
        {
            RockMigrationHelper.AddGroupTypeGroupAttribute(
                SystemGuid.GroupType.GROUPTYPE_FUNDRAISINGOPPORTUNITY,
                SystemGuid.FieldType.DATE,
                "Allow Donations Until",
                "Donations to members of this group will be allowed up to and including the date specified.",
                0,
                string.Empty,
                AllowDonationsUntilGuid,
                false);

            Sql($@"
                DECLARE @Order int = (SELECT [Order] + 1 FROM [Attribute] WHERE [Guid] = '7C6FF01B-F68E-4A83-A96D-85071A92AAF1')
                
                -- Update Order on the new attribute
                UPDATE [Attribute]
                    SET [Order] = @Order
                WHERE [Guid] = '{AllowDonationsUntilGuid}'
                
                -- Update Order on the Show Public and Registration Notes attributes
                UPDATE [Attribute]
                    SET [Order] = [Order] + 1
                WHERE [Guid] IN ('BBD6C818-765C-43FB-AA72-5AF66F91B499', '7360CF56-7DF5-42E9-AD2B-AD839E0D4EDB') AND [Order] >= @Order");
        }
        /// <summary>
        /// Operations to be performed during the upgrade process.
        /// </summary>
        public override void Up()
        {
            DropForeignKey("dbo.BenevolenceResult", "BenevolenceRequestId", "dbo.BenevolenceRequest");
            AddForeignKey("dbo.BenevolenceResult", "BenevolenceRequestId", "dbo.BenevolenceRequest", "Id", cascadeDelete: true);

            RockMigrationHelper.AddGroupTypeGroupAttribute("2C42B2D4-1C5F-4AD5-A9AD-08631B872AC4", "1EDAFDED-DFE6-4334-B019-6EECBA89E05A", "Requires Background Check", "Is a background check required to serve on this team?", 0, "", "6DC6E992-4CAF-4C9F-B11D-5918D244BD40");

            RockMigrationHelper.UpdateEntityType("Rock.Workflow.Action.AddPersonToGroup", "Add Person to Specified Group", "Rock.Workflow.Action.AddPersonToGroup, Rock, Version=1.3.1.0, Culture=neutral, PublicKeyToken=null", false, true, "DF0167A1-6928-4FBC-893B-5826A28AAC83");
            RockMigrationHelper.UpdateEntityType("Rock.Workflow.Action.AddPersonToGroupWFAttribute", "Add Person to Group using Workflow Attribute", "Rock.Workflow.Action.AddPersonToGroupWFAttribute, Rock, Version=1.3.1.0, Culture=neutral, PublicKeyToken=null", false, true, "BD53F375-78A2-4A54-B1D1-2D805F3FCD44");
        }
Ejemplo n.º 6
0
 public override void Up()
 {
     RockMigrationHelper.AddGroupType("Rise Learning Group", "Groups that are mirrored in the Rise learning management system.",
                                      "Group", "Member", false, true, true, "fa fa-chalkboard", 100, "", 0, "", Constants.GROUPTYPE_RISE);
     RockMigrationHelper.AddGroupTypeRole(Constants.GROUPTYPE_RISE, "Learner", "", 0, null, null,
                                          "41DF5756-4D66-4BDE-841A-300C25680354", true, false, true);
     RockMigrationHelper.AddGroupTypeGroupAttribute(Constants.GROUPTYPE_RISE, Rock.SystemGuid.FieldType.TEXT, "Rise Group Id",
                                                    "The id of the group in the Rise learning system.", 0, "", Constants.GROUP_ATTRIBUTE_RISEID);
     RockMigrationHelper.AddGroupTypeGroupAttribute(Constants.GROUPTYPE_RISE, Rock.SystemGuid.FieldType.TEXT, "Rise Group Url",
                                                    "The url of the group in the Rise learning system.", 1, "", "ABF5A7DA-B8B7-4446-8124-139CE3E90870");
 }
Ejemplo n.º 7
0
 /// <summary>
 /// The commands to run to migrate plugin to the specific version
 /// </summary>
 public override void Up()
 {
     RockMigrationHelper.AddGroupTypeGroupAttribute(
         Rock.SystemGuid.GroupType.GROUPTYPE_FAMILY,
         Rock.SystemGuid.FieldType.TEXT,
         "League Apps Family Id",
         "Family id for league apps",
         999,
         "",
         Constants.ATTRIBUTE_GROUP_FAMILY_ID,
         false
         );
 }
Ejemplo n.º 8
0
        public override void Up()
        {
            RockMigrationHelper.AddGroupTypeGroupAttribute(Constants.GROUP_TYPE_BY_MEMBERSHIP, Rock.SystemGuid.FieldType.SINGLE_SELECT, "Check Requirements",
                                                           "Should the requirements of the group be checked before allowing check-in. This is slower but needed in some situations.",
                                                           5, "0", Constants.GROUP_ATTRIBUTE_CHECK_REQUIREMENTS, false);
            RockMigrationHelper.AddAttributeQualifier(Constants.GROUP_ATTRIBUTE_CHECK_REQUIREMENTS, "values", "0^Do Not Check,1^Check Required Only,2^Check Required and Warning", "9E659023-6860-4872-B7C9-EB019FF76145");

            RockMigrationHelper.AddGroupTypeGroupAttribute(Constants.GROUP_TYPE_BY_MEMBERSHIP, Rock.SystemGuid.FieldType.SINGLE_SELECT, "Member Role",
                                                           "Optional filter to only allow people if they are a member or leader.",
                                                           6, "0", Constants.GROUP_ATTRIBUTE_MEMBER_ROLE, false);
            RockMigrationHelper.AddAttributeQualifier(Constants.GROUP_ATTRIBUTE_MEMBER_ROLE, "values", "0^Any,1^Leaders Only,2^Non Leaders Only", "840B04D7-DC1B-452B-A869-0AEB4904DC26");

            RockMigrationHelper.AddGroupTypeGroupAttribute(Constants.GROUP_TYPE_BY_MEMBERSHIP, Rock.SystemGuid.FieldType.BOOLEAN, "Save Attendance To Group",
                                                           "If selected, the attendance will be set on the group the person is a member of instead of on the check-in group.",
                                                           7, "False", Constants.GROUP_ATTRIBUTE_ATTENDANCE_ON_GROUP);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// The commands to run to migrate plugin to the specific version
        /// </summary>
        public override void Up()
        {
            // reset the attribute key
            Sql(@"
                UPDATE [Attribute]
                SET [Key] = 'LoadBalanceLocations'
                WHERE [Guid] = '14631054-CCEE-4033-98A6-F27144C943AD'
	            OR [Guid] = 'D4B27829-494F-4A45-8A89-5389B3D84B14'
            ");

            // add to checkin by age (inherited by ability and grade)
            RockMigrationHelper.AddGroupTypeGroupAttribute("0572A5FE-20A4-4BF1-95CD-C71DB5281392", Rock.SystemGuid.FieldType.BOOLEAN, "Load Balance Locations", "Flag indicating if the locations for this group should be presented by current attendance when the person does not have a history.", 3, @"False", "14631054-CCEE-4033-98A6-F27144C943AD");

            // add to checkin
            RockMigrationHelper.AddGroupTypeGroupAttribute("6E7AD783-7614-4721-ABC1-35842113EF59", Rock.SystemGuid.FieldType.BOOLEAN, "Load Balance Locations", "Flag indicating if the locations for this group should be presented by current attendance when the person does not have a history.", 0, @"False", "D4B27829-494F-4A45-8A89-5389B3D84B14");

            // set the attribute key
            Sql(@"
                UPDATE [Attribute]
                SET [Key] = 'rocks.kfs.LoadBalanceLocations'
                WHERE [Guid] = '14631054-CCEE-4033-98A6-F27144C943AD'
	            OR [Guid] = 'D4B27829-494F-4A45-8A89-5389B3D84B14'
            ");
        }
        /// <summary>
        /// Operations to be performed during the upgrade process.
        /// </summary>
        public override void Up()
        {
            CreateIndex("dbo.Communication", "ListGroupId");

            // Instead of AddForeignKey, do it manually so it can be a ON DELETE SET NULL
            // AddForeignKey("dbo.Communication", "ListGroupId", "dbo.Group", "Id");
            Sql(@"ALTER TABLE dbo.Communication ADD CONSTRAINT [FK_dbo.Communication_dbo.Group_ListGroupId] 
                  FOREIGN KEY (ListGroupId) REFERENCES dbo.[Group] (Id) ON DELETE SET NULL");

            // MP: Add optional SecurityColumn to GroupList and enable for Communication List
            // Attrib for BlockType: Group List:Display Security Column
            RockMigrationHelper.UpdateBlockTypeAttribute("3D7FB6BE-6BBD-49F7-96B4-96310AF3048A", "1EDAFDED-DFE6-4334-B019-6EECBA89E05A", "Display Security Column", "DisplaySecurityColumn", "", "Should the Security column be displayed?", 10, @"False", "2DDD4FD0-5E03-4271-B8EF-728DECA10018");
            // Attrib Value for Block:Group List, Attribute:core.CustomGridColumnsConfig Page: Communication Lists, Site: Rock RMS
            RockMigrationHelper.AddBlockAttributeValue("426EC86B-5784-411D-94ED-DD007E6DF783", "487A898B-2192-459D-9546-32AE3EE9A9C5", @"{
 ""ColumnsConfig"": [
 {
 ""HeaderText"": """",
 ""HeaderClass"": ""grid-columncommand"",
 ""ItemClass"": ""grid-columncommand"",
 ""LavaTemplate"": ""<div class='text-center'>\n <a href='~/EmailAnalytics?CommunicationListId={{Row.Id}}' class='btn btn-default btn-sm' title='Email Analytics'>\n <i class='fa fa-line-chart'></i>\n </a>\n</div>"",
 ""PositionOffsetType"": 1,
 ""PositionOffset"": 2
 }
 ]
}");
            // Attrib Value for Block:Group List, Attribute:Display Security Column Page: Communication Lists, Site: Rock RMS
            RockMigrationHelper.AddBlockAttributeValue("426EC86B-5784-411D-94ED-DD007E6DF783", "2DDD4FD0-5E03-4271-B8EF-728DECA10018", @"True");


            // MP: Update EmailMedium AttributeValues
            Sql(MigrationSQL._201710061805334_CommunicationListGroup_UpdateEmailMediumAttributeValues);

            // MP: Communication List Public Name
            // 'Public Name' group attribute for Communication List
            RockMigrationHelper.AddGroupTypeGroupAttribute("D1D95777-FFA3-CBB3-4A6D-658706DAED33", SystemGuid.FieldType.TEXT, "Public Name", "The name of the communication list that is shown publicly.", 0, "", "086104F3-EE6B-4557-BBD1-9533C8023267");

            // MP: More Catchups
            RockMigrationHelper.UpdateBlockType("Bulk Import", "Block to import Slingshot files into Rock using BulkImport", "~/Blocks/BulkImport/BulkImportTool.ascx", "Bulk Import", "D9302E4A-C498-4CD7-8D3B-0E9DA9802DD5");
            // Attrib for BlockType: Login:New Account Text
            RockMigrationHelper.UpdateBlockTypeAttribute("7B83D513-1178-429E-93FF-E76430E038E4", "9C204CD0-1233-41C5-818A-C5DA439445AA", "New Account Text", "NewAccountButtonText", "", "The text to show on the New Account button.", 7, @"Register", "C76DC2DA-E1CB-4AAB-AD1F-573FFF726805");
            // Attrib for BlockType: My Workflows Lava:Set Panel Icon
            RockMigrationHelper.UpdateBlockTypeAttribute("4F217A7F-A34E-489E-AE0E-2B7EDCF69CD1", "9C204CD0-1233-41C5-818A-C5DA439445AA", "Set Panel Icon", "SetPanelIcon", "", "The icon to display in the panel header.", 5, @"", "0BB2EE44-5790-4861-A556-25E280A8858C");
            // Attrib for BlockType: My Workflows Lava:Set Panel Title
            RockMigrationHelper.UpdateBlockTypeAttribute("4F217A7F-A34E-489E-AE0E-2B7EDCF69CD1", "9C204CD0-1233-41C5-818A-C5DA439445AA", "Set Panel Title", "SetPanelTitle", "", "The title to display in the panel header. Leave empty to have the block name.", 4, @"", "290E180A-0433-48D1-9BB2-4A9A46E2D60D");
            // Attrib for BlockType: Group List:Set Panel Title
            RockMigrationHelper.UpdateBlockTypeAttribute("3D7FB6BE-6BBD-49F7-96B4-96310AF3048A", "9C204CD0-1233-41C5-818A-C5DA439445AA", "Set Panel Title", "SetPanelTitle", "", "The title to display in the panel header. Leave empty to have the title be set automatically based on the group type or block name.", 13, @"", "E861BE97-59F3-4A9C-8F9E-8F45798DF26C");
            // Attrib for BlockType: Group List:Set Panel Icon
            RockMigrationHelper.UpdateBlockTypeAttribute("3D7FB6BE-6BBD-49F7-96B4-96310AF3048A", "9C204CD0-1233-41C5-818A-C5DA439445AA", "Set Panel Icon", "SetPanelIcon", "", "The icon to display in the panel header. Leave empty to have the icon be set automatically based on the group type or default icon.", 14, @"", "A03E361B-3F13-41C4-B92F-59A42C261569");
            // Attrib for BlockType: Email Analytics:Series Colors
            RockMigrationHelper.UpdateBlockTypeAttribute("7B506760-93FA-4FBF-9FB5-0D9C3E36DCCD", "9C204CD0-1233-41C5-818A-C5DA439445AA", "Series Colors", "SeriesColors", "", "A comma-delimited list of colors that the charts will use.", 0, @"#5DA5DA,#60BD68,#FFBF2F,#F36F13,#C83013,#676766", "0EF39AAC-E6EA-426B-802A-3212CE52F245");
            // Attrib for BlockType: Public Profile Edit:Request Changes Text
            RockMigrationHelper.UpdateBlockTypeAttribute("841D1670-8BFD-4913-8409-FB47EB7A2AB9", "9C204CD0-1233-41C5-818A-C5DA439445AA", "Request Changes Text", "RequestChangesText", "", "The text to use for the request changes button (only displayed if there is a 'Workflow Launch Page' configured).", 7, @"Request Additional Changes", "1B56C327-758E-401F-A9C8-5E414DDC6F7D");
            // Attrib for BlockType: Person Bio:Display Anniversary Date
            RockMigrationHelper.UpdateBlockTypeAttribute("0F5922BB-CD68-40AC-BF3C-4AAB1B98760C", "1EDAFDED-DFE6-4334-B019-6EECBA89E05A", "Display Anniversary Date", "DisplayAnniversaryDate", "", "Should the Anniversary Date be displayed?", 12, @"True", "D6B98FBE-A10E-4C29-B033-1BF949391212");
            // Attrib for BlockType: Person Bio:Display Tags
            RockMigrationHelper.UpdateBlockTypeAttribute("0F5922BB-CD68-40AC-BF3C-4AAB1B98760C", "1EDAFDED-DFE6-4334-B019-6EECBA89E05A", "Display Tags", "DisplayTags", "", "Should tags be displayed?", 10, @"True", "9217579B-C0DE-4D2F-BBE3-DE75E2D239E1");
            // Attrib for BlockType: Person Bio:Display Graduation
            RockMigrationHelper.UpdateBlockTypeAttribute("0F5922BB-CD68-40AC-BF3C-4AAB1B98760C", "1EDAFDED-DFE6-4334-B019-6EECBA89E05A", "Display Graduation", "DisplayGraduation", "", "Should the Grade/Graduation be displayed", 11, @"True", "59C6A71C-7064-4D23-A5D5-04FA8F1B3456");
            // Attrib for BlockType: Notes:Display Note Type Heading
            RockMigrationHelper.UpdateBlockTypeAttribute("2E9F32D4-B4FC-4A5F-9BE1-B2E3EA624DD3", "1EDAFDED-DFE6-4334-B019-6EECBA89E05A", "Display Note Type Heading", "DisplayNoteTypeHeading", "", "Should each note's Note Type be displayed as a heading above each note?", 13, @"False", "C5FD0719-1E03-4C17-BE31-E02A3637C39A");
            // Attrib for BlockType: Group List:Display Security Column
            RockMigrationHelper.UpdateBlockTypeAttribute("3D7FB6BE-6BBD-49F7-96B4-96310AF3048A", "1EDAFDED-DFE6-4334-B019-6EECBA89E05A", "Display Security Column", "DisplaySecurityColumn", "", "Should the Security column be displayed?", 10, @"False", "2DDD4FD0-5E03-4271-B8EF-728DECA10018");
            // Attrib for BlockType: Group Detail:Show Location Addresses
            RockMigrationHelper.UpdateBlockTypeAttribute("582BEEA1-5B27-444D-BC0A-F60CEB053981", "1EDAFDED-DFE6-4334-B019-6EECBA89E05A", "Show Location Addresses", "ShowLocationAddresses", "", "Determines if the location address should be shown when viewing the group details.", 13, @"True", "8A2D0F83-0856-4963-A600-095391603661");
            // Attrib for BlockType: Group Detail:Prevent Selecting Inactive Campus
            RockMigrationHelper.UpdateBlockTypeAttribute("582BEEA1-5B27-444D-BC0A-F60CEB053981", "1EDAFDED-DFE6-4334-B019-6EECBA89E05A", "Prevent Selecting Inactive Campus", "PreventSelectingInactiveCampus", "", "Should inactive campuses be excluded from the campus field when editing a group?.", 14, @"False", "7268FBA7-B88B-4CFD-B34B-4F6ACFE80BC2");
            // Attrib for BlockType: Edit Person:Hide Anniversary Date
            RockMigrationHelper.UpdateBlockTypeAttribute("0A15F28C-4828-4B38-AF66-58AC5BDE48E0", "1EDAFDED-DFE6-4334-B019-6EECBA89E05A", "Hide Anniversary Date", "HideAnniversaryDate", "", "Should the Anniversary Date field be hidden?", 1, @"False", "EA1869F0-1E2A-4DF9-AF2C-32A4733624D5");
            // Attrib for BlockType: Edit Person:Hide Grade
            RockMigrationHelper.UpdateBlockTypeAttribute("0A15F28C-4828-4B38-AF66-58AC5BDE48E0", "1EDAFDED-DFE6-4334-B019-6EECBA89E05A", "Hide Grade", "HideGrade", "", "Should the Grade (and Graduation Year) fields be hidden?", 0, @"False", "2B823000-A6DA-4105-8FAC-ADD09D3A7E3E");
            // Attrib for BlockType: Content Channel View:Enable Legacy Global Attribute Lava
            RockMigrationHelper.UpdateBlockTypeAttribute("143A2345-3E26-4ED0-A2FE-42AAF11B4C0F", "1EDAFDED-DFE6-4334-B019-6EECBA89E05A", "Enable Legacy Global Attribute Lava", "SupportLegacy", "", "This should only be enabled if your lava is using legacy Global Attributes. Enabling this option, will negatively affect the performance of this block.", 2, @"False", "B1A62B09-92DF-41D1-8698-6B6F7DE1DD36");
            // Attrib for BlockType: Public Profile Edit:Disable Name Edit
            RockMigrationHelper.UpdateBlockTypeAttribute("841D1670-8BFD-4913-8409-FB47EB7A2AB9", "1EDAFDED-DFE6-4334-B019-6EECBA89E05A", "Disable Name Edit", "DisableNameEdit", "", "Whether the First and Last Names can be edited.", 0, @"False", "5B3ECBBE-293C-4BA6-A5D8-87846D4F641C");
            // Attrib for BlockType: Public Profile Edit:View Only
            RockMigrationHelper.UpdateBlockTypeAttribute("841D1670-8BFD-4913-8409-FB47EB7A2AB9", "1EDAFDED-DFE6-4334-B019-6EECBA89E05A", "View Only", "ViewOnly", "", "Should people be prevented from editing thier profile or family records?", 1, @"False", "13E4D341-CEEF-4B7E-BB3F-6FF5B3466817");
            // Attrib for BlockType: Public Profile Edit:Show Communication Preference
            RockMigrationHelper.UpdateBlockTypeAttribute("841D1670-8BFD-4913-8409-FB47EB7A2AB9", "1EDAFDED-DFE6-4334-B019-6EECBA89E05A", "Show Communication Preference", "ShowCommunicationPreference", "", "Show the communication preference and allow it to be edited", 5, @"True", "8466A07F-4C0E-4B31-8AE5-F6BE96AB56F4");
            // Attrib for BlockType: Workflow Entry:Show Summary View
            RockMigrationHelper.UpdateBlockTypeAttribute("A8BD05C8-6F89-4628-845B-059E686F089A", "1EDAFDED-DFE6-4334-B019-6EECBA89E05A", "Show Summary View", "ShowSummaryView", "", "If workflow has been completed, should the summary view be displayed?", 1, @"False", "1CFB44EE-4DF7-40DD-83DC-B7801909D259");
            // Attrib for BlockType: Relationships:Max Relationships To Display
            RockMigrationHelper.UpdateBlockTypeAttribute("77E409D4-11CD-4009-B4CD-4B75DF2CC9FD", "A75DFC58-7A1B-4799-BF31-451B2BBE38FF", "Max Relationships To Display", "MaxRelationshipsToDisplay", "", "", 0, @"50", "15982494-746F-48F0-9634-F045583A05FC");
            // Attrib for BlockType: Content Channel View:Output Cache Duration
            RockMigrationHelper.UpdateBlockTypeAttribute("143A2345-3E26-4ED0-A2FE-42AAF11B4C0F", "A75DFC58-7A1B-4799-BF31-451B2BBE38FF", "Output Cache Duration", "OutputCacheDuration", "", "Number of seconds to cache the resolved output. Only cache the output if you are not personalizing the output based on current user, current page, or any other merge field value.", 0, @"0", "8B21B333-9875-4231-B83D-4E007409BF30");
            // Attrib for BlockType: Group List Personalized Lava:Cache Duration
            RockMigrationHelper.UpdateBlockTypeAttribute("1B172C33-8672-4C98-A995-8E123FF316BD", "A75DFC58-7A1B-4799-BF31-451B2BBE38FF", "Cache Duration", "CacheDuration", "", "Length of time in seconds to cache which groups are descendants of the parent group.", 3, @"3600", "CCA08E73-78F6-46A5-831F-7BEB8C213ACD");
            // Attrib for BlockType: Communication List:Email Analytics
            RockMigrationHelper.UpdateBlockTypeAttribute("56ABBD0F-8F62-4094-88B3-161E71F21419", "BD53F9C9-EBA9-4D3F-82EA-DE5DD34A8108", "Email Analytics", "EmailAnalytics", "", "", 2, @"DF014200-72A3-48A0-A953-E594E5410E36", "0B28D804-634A-40CF-AF8B-BD37E1E7A7C6");
            // Attrib for BlockType: Email Preference Entry:Unsubscribe from List Text
            RockMigrationHelper.UpdateBlockTypeAttribute("B3C076C7-1325-4453-9549-456C23702069", "C28C7BF3-A552-4D77-9408-DEDCF760CED0", "Unsubscribe from List Text", "UnsubscribefromListText", "", "Text to display for the 'Unsubscribe me from list' option.", 1, @"Please unsubscribe me from emails regarding '{{ Communication.ListGroup | Attribute:'PublicName' | Default:Communication.ListGroup.Name }}'", "A09E8C9D-F6CD-4BFC-9CF4-2C9B7DBB9953");
            // Attrib for BlockType: Email Preference Entry:Unsubscribe Success Text
            RockMigrationHelper.UpdateBlockTypeAttribute("B3C076C7-1325-4453-9549-456C23702069", "C28C7BF3-A552-4D77-9408-DEDCF760CED0", "Unsubscribe Success Text", "UnsubscribeSuccessText", "", "Text to display after user unsubscribes from a list.", 7, @"<h4>Thank You</h4>We have saved your removed you from the '{{ Communication.ListGroup | Attribute:'PublicName' | Default:Communication.ListGroup.Name }}' list.", "267739E4-A231-4E4C-A58C-9BFDA3C2948C");
            // Attrib for BlockType: Group List Personalized Lava:Parent Group
            RockMigrationHelper.UpdateBlockTypeAttribute("1B172C33-8672-4C98-A995-8E123FF316BD", "F4399CEF-827B-48B2-A735-F7806FCFE8E8", "Parent Group", "ParentGroup", "", "If a group is chosen, only the groups under this group will be displayed.", 2, @"", "D5F64AB6-2296-491F-A2F0-1B6660F3E878");
            // Attrib for BlockType: Login:No Account Text
            RockMigrationHelper.UpdateBlockTypeAttribute("7B83D513-1178-429E-93FF-E76430E038E4", "1D0D3794-C210-48A8-8C68-3FBEC08A6BA5", "No Account Text", "NoAccountText", "", "The text to show when no account exists. <span class='tip tip-lava'></span>.", 8, @"Sorry, we couldn't find an account matching that username/password. Can we help you <a href='{{HelpPage}}'>recover your account information</a>?", "A33F3913-78E0-463B-9861-64611B4E7B31");
            // Attrib for BlockType: Login:Invalid PersonToken Text
            RockMigrationHelper.UpdateBlockTypeAttribute("7B83D513-1178-429E-93FF-E76430E038E4", "1D0D3794-C210-48A8-8C68-3FBEC08A6BA5", "Invalid PersonToken Text", "InvalidPersonTokenText", "", "The text to show when a person is logged out due to an invalid persontoken. <span class='tip tip-lava'></span>.", 12, @"<div class='alert alert-warning'>The login token you provided is no longer valid. Please login below.</div>", "734324B5-AC54-408C-B9B7-ABC31745B0DE");
            // Attrib for BlockType: Group Members:Group Footer Lava
            RockMigrationHelper.UpdateBlockTypeAttribute("FC137BDA-4F05-4ECE-9899-A249C90D11FC", "1D0D3794-C210-48A8-8C68-3FBEC08A6BA5", "Group Footer Lava", "GroupFooterLava", "", "Lava to put at the bottom of the block. Merge fields include Page, CurrentPerson, Group (the family) and GroupMembers.", 5, @"", "7CA36124-D14C-44E8-89EA-DE3845630B97");
            // Attrib for BlockType: Group Members:Group Header Lava
            RockMigrationHelper.UpdateBlockTypeAttribute("FC137BDA-4F05-4ECE-9899-A249C90D11FC", "1D0D3794-C210-48A8-8C68-3FBEC08A6BA5", "Group Header Lava", "GroupHeaderLava", "", "Lava to put at the top of the block. Merge fields include Page, CurrentPerson, Group (the family) and GroupMembers.", 4, @"", "2B06CE66-DD84-47B9-9205-00A72DB75063");
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Operations to be performed during the upgrade process.
        /// </summary>
        public override void Up()
        {
            RockMigrationHelper.UpdateFieldType("Data Views", "", "Rock", "Rock.Field.Types.DataViewsFieldType", "F739BF5D-3FDC-45EC-A03C-1AE7C47E3883");
            RockMigrationHelper.UpdateFieldType("Communication Preference", "", "Rock", "Rock.Field.Types.CommunicationPreferenceFieldType", "507C28F2-8BC0-4909-A4FE-9C2B1149E2B2");

            DropForeignKey("dbo.Communication", "MediumEntityTypeId", "dbo.EntityType");
            Sql(@"
IF object_id(N'[dbo].[FK_dbo.Communication_dbo.EntityType_ChannelEntityTypeId]', N'F') IS NOT NULL
    ALTER TABLE [dbo].[Communication] DROP CONSTRAINT [FK_dbo.Communication_dbo.EntityType_ChannelEntityTypeId]
");
            DropForeignKey("dbo.CommunicationTemplate", "MediumEntityTypeId", "dbo.EntityType");
            Sql(@"
IF object_id(N'[dbo].[FK_dbo.CommunicationTemplate_dbo.EntityType_ChannelEntityTypeId]', N'F') IS NOT NULL
    ALTER TABLE [dbo].[CommunicationTemplate] DROP CONSTRAINT [FK_dbo.CommunicationTemplate_dbo.EntityType_ChannelEntityTypeId]
");
            DropIndex("dbo.Communication", new[] { "MediumEntityTypeId" });
            DropIndex("dbo.CommunicationTemplate", new[] { "MediumEntityTypeId" });
            CreateTable(
                "dbo.CommunicationAttachment",
                c => new
            {
                Id                      = c.Int(nullable: false, identity: true),
                BinaryFileId            = c.Int(nullable: false),
                CommunicationId         = c.Int(nullable: false),
                CreatedDateTime         = c.DateTime(),
                ModifiedDateTime        = c.DateTime(),
                CreatedByPersonAliasId  = c.Int(),
                ModifiedByPersonAliasId = c.Int(),
                Guid                    = c.Guid(nullable: false),
                ForeignId               = c.Int(),
                ForeignGuid             = c.Guid(),
                ForeignKey              = c.String(maxLength: 100),
            })
            .PrimaryKey(t => t.Id)
            .ForeignKey("dbo.BinaryFile", t => t.BinaryFileId)
            .ForeignKey("dbo.Communication", t => t.CommunicationId, cascadeDelete: true)
            .ForeignKey("dbo.PersonAlias", t => t.CreatedByPersonAliasId)
            .ForeignKey("dbo.PersonAlias", t => t.ModifiedByPersonAliasId)
            .Index(t => t.BinaryFileId)
            .Index(t => t.CommunicationId)
            .Index(t => t.CreatedByPersonAliasId)
            .Index(t => t.ModifiedByPersonAliasId)
            .Index(t => t.Guid, unique: true);

            CreateTable(
                "dbo.CommunicationTemplateAttachment",
                c => new
            {
                Id                      = c.Int(nullable: false, identity: true),
                BinaryFileId            = c.Int(nullable: false),
                CommunicationTemplateId = c.Int(nullable: false),
                CreatedDateTime         = c.DateTime(),
                ModifiedDateTime        = c.DateTime(),
                CreatedByPersonAliasId  = c.Int(),
                ModifiedByPersonAliasId = c.Int(),
                Guid                    = c.Guid(nullable: false),
                ForeignId               = c.Int(),
                ForeignGuid             = c.Guid(),
                ForeignKey              = c.String(maxLength: 100),
            })
            .PrimaryKey(t => t.Id)
            .ForeignKey("dbo.BinaryFile", t => t.BinaryFileId)
            .ForeignKey("dbo.CommunicationTemplate", t => t.CommunicationTemplateId, cascadeDelete: true)
            .ForeignKey("dbo.PersonAlias", t => t.CreatedByPersonAliasId)
            .ForeignKey("dbo.PersonAlias", t => t.ModifiedByPersonAliasId)
            .Index(t => t.BinaryFileId)
            .Index(t => t.CommunicationTemplateId)
            .Index(t => t.CreatedByPersonAliasId)
            .Index(t => t.ModifiedByPersonAliasId)
            .Index(t => t.Guid, unique: true);

            AddColumn("dbo.Person", "CommunicationPreference", c => c.Int(nullable: false));
            AddColumn("dbo.CommunicationRecipient", "MediumEntityTypeId", c => c.Int());
            AddColumn("dbo.Communication", "Name", c => c.String(maxLength: 100));
            AddColumn("dbo.Communication", "CommunicationType", c => c.Int(nullable: false));
            AddColumn("dbo.Communication", "UrlReferrer", c => c.String(maxLength: 200));
            AddColumn("dbo.Communication", "ListGroupId", c => c.Int());
            AddColumn("dbo.Communication", "Segments", c => c.String());
            AddColumn("dbo.Communication", "SegmentCriteria", c => c.Int(nullable: false));
            AddColumn("dbo.Communication", "CommunicationTemplateId", c => c.Int());
            AddColumn("dbo.Communication", "FromName", c => c.String(maxLength: 100));
            AddColumn("dbo.Communication", "FromEmail", c => c.String(maxLength: 100));
            AddColumn("dbo.Communication", "ReplyToEmail", c => c.String(maxLength: 100));
            AddColumn("dbo.Communication", "CCEmails", c => c.String());
            AddColumn("dbo.Communication", "BCCEmails", c => c.String());
            AddColumn("dbo.Communication", "Message", c => c.String());
            AddColumn("dbo.Communication", "MessageMetaData", c => c.String());
            AddColumn("dbo.Communication", "SMSFromDefinedValueId", c => c.Int());
            AddColumn("dbo.Communication", "SMSMessage", c => c.String());
            AddColumn("dbo.Communication", "PushTitle", c => c.String(maxLength: 100));
            AddColumn("dbo.Communication", "PushMessage", c => c.String());
            AddColumn("dbo.Communication", "PushSound", c => c.String(maxLength: 100));
            AddColumn("dbo.CommunicationTemplate", "IsSystem", c => c.Boolean(nullable: false));
            AddColumn("dbo.CommunicationTemplate", "ImageFileId", c => c.Int());
            AddColumn("dbo.CommunicationTemplate", "FromName", c => c.String(maxLength: 100));
            AddColumn("dbo.CommunicationTemplate", "FromEmail", c => c.String(maxLength: 100));
            AddColumn("dbo.CommunicationTemplate", "ReplyToEmail", c => c.String(maxLength: 100));
            AddColumn("dbo.CommunicationTemplate", "CCEmails", c => c.String());
            AddColumn("dbo.CommunicationTemplate", "BCCEmails", c => c.String());
            AddColumn("dbo.CommunicationTemplate", "Message", c => c.String());
            AddColumn("dbo.CommunicationTemplate", "MessageMetaData", c => c.String());
            AddColumn("dbo.CommunicationTemplate", "SMSFromDefinedValueId", c => c.Int());
            AddColumn("dbo.CommunicationTemplate", "SMSMessage", c => c.String());
            AddColumn("dbo.CommunicationTemplate", "PushTitle", c => c.String(maxLength: 100));
            AddColumn("dbo.CommunicationTemplate", "PushMessage", c => c.String());
            AddColumn("dbo.CommunicationTemplate", "PushSound", c => c.String(maxLength: 100));

            // Moved Index Creating to MigrateCommunicationMediumData job since it could take a while
            //CreateIndex("dbo.CommunicationRecipient", "MediumEntityTypeId");
            //CreateIndex("dbo.Communication", "CommunicationTemplateId");
            //CreateIndex("dbo.Communication", "SMSFromDefinedValueId");
            //CreateIndex("dbo.CommunicationTemplate", "SMSFromDefinedValueId");
            AddForeignKey("dbo.CommunicationTemplate", "SMSFromDefinedValueId", "dbo.DefinedValue", "Id");
            AddForeignKey("dbo.Communication", "SMSFromDefinedValueId", "dbo.DefinedValue", "Id");

            // Moved to MigrateCommunicationMediumData job since it could take a while
            //AddForeignKey("dbo.CommunicationRecipient", "MediumEntityTypeId", "dbo.EntityType", "Id");
            //AddForeignKey("dbo.Communication", "CommunicationTemplateId", "dbo.CommunicationTemplate", "Id");

            // Instead of AddForeignKey, do it manually so it can be a ON DELETE SET NULL
            Sql(@"ALTER TABLE dbo.Communication ADD CONSTRAINT [FK_dbo.Communication_dbo.CommunicationTemplate_CommunicationTemplateId] 
                    FOREIGN KEY (CommunicationTemplateId) REFERENCES dbo.CommunicationTemplate (Id) ON DELETE SET NULL");

            Sql(@"
    UPDATE C 
        SET [CommunicationType] = CASE E.[Name]
            WHEN 'Rock.Communication.Medium.Email' THEN 1
            WHEN 'Rock.Communication.Medium.Sms' THEN 2
            WHEN 'Rock.Communication.Medium.PushNotification' THEN 3
            WHEN 'com.bricksandmortarstudio.Communication.Medium.AlphanumericSMS' THEN 2
            ELSE 4
        END
    FROM [Communication] C
    INNER JOIN [EntityType] E ON E.[Id] = C.[MediumEntityTypeId]
");

            // Drop any custom indexes that might be referencing Communication.MediumEntityTypeId column
            Sql(@"DECLARE @sql NVARCHAR(MAX) = ''

BEGIN
	SELECT @sql += CONCAT (
			'DROP INDEX '
			,object_name(ic.object_id)
			,'.'
			,I.name
			,CHAR(10)
			)
	FROM sys.indexes i
	INNER JOIN sys.index_columns ic ON ic.object_id = i.object_id
		AND ic.index_id = i.index_id
	INNER JOIN sys.columns c ON c.object_id = ic.object_id
		AND c.column_id = ic.column_id
	WHERE c.Name = 'MediumEntityTypeId'
		AND object_name(ic.object_id) = 'Communication'

	EXEC (@sql)
END");


            DropColumn("dbo.Communication", "MediumEntityTypeId");

            // Drop any custom indexes that might be referencing CommunicationTemplate.MediumEntityTypeId column
            Sql(@"DECLARE @sql NVARCHAR(MAX) = ''

BEGIN
	SELECT @sql += CONCAT (
			'DROP INDEX '
			,object_name(ic.object_id)
			,'.'
			,I.name
			,CHAR(10)
			)
	FROM sys.indexes i
	INNER JOIN sys.index_columns ic ON ic.object_id = i.object_id
		AND ic.index_id = i.index_id
	INNER JOIN sys.columns c ON c.object_id = ic.object_id
		AND c.column_id = ic.column_id
	WHERE c.Name = 'MediumEntityTypeId'
		AND object_name(ic.object_id) = 'CommunicationTemplate'

	EXEC (@sql)
END");
            DropColumn("dbo.CommunicationTemplate", "MediumEntityTypeId");

            Sql(MigrationSQL._201709082257551_Communications2_AddCommunicationTemplates);

            // group type
            RockMigrationHelper.AddGroupType("Communication List", "For groups used by Rock's communication tools for storing lists of people to communicate to.", "List", "Recipient", false, true, false, "fa fa-bullhorn", 0, null, 0, null, "D1D95777-FFA3-CBB3-4A6D-658706DAED33");
            RockMigrationHelper.AddGroupTypeRole("D1D95777-FFA3-CBB3-4A6D-658706DAED33", "Recipient", "", 0, null, null, "9D85AB4E-59BC-B48A-494A-5684BA41578E", true, false, true);

            // group attribute
            RockMigrationHelper.AddGroupTypeGroupAttribute("D1D95777-FFA3-CBB3-4A6D-658706DAED33", SystemGuid.FieldType.DATAVIEWS, "Communication Segments", "Additional Communication Segments to be presented when this communication list is selected.", 0, "", "73A53BC1-2178-46A1-8413-C7A4DD49F0B4");
            RockMigrationHelper.AddAttributeQualifier("73A53BC1-2178-46A1-8413-C7A4DD49F0B4", "entityTypeName", "Rock.Model.Person", "37C5CD82-C4D2-4B58-BBCB-D2D59EF4B200");

            // group member attribute
            RockMigrationHelper.AddGroupTypeGroupMemberAttribute("D1D95777-FFA3-CBB3-4A6D-658706DAED33", SystemGuid.FieldType.COMMUNICATION_PREFERENCE_TYPE, "Preferred Communication Type", "The preferred communication type for this group member. Select None to use the person's default communication preference.", 0, "0", "D7941908-1F65-CC9B-416C-CCFABE4221B9");
            RockMigrationHelper.AddAttributeQualifier("D7941908-1F65-CC9B-416C-CCFABE4221B9", "allowmultiple", "False", "AEB4720A-B053-8D92-407E-9B29564882D2");
            RockMigrationHelper.AddAttributeQualifier("D7941908-1F65-CC9B-416C-CCFABE4221B9", "displaydescription", "False", "3A85C857-43E1-6586-41E5-9E9DF7D7D6B0");

            Sql(@"DECLARE @AttributeId int = (SELECT TOP 1 [Id] FROM [Attribute] WHERE [Guid] = 'D7941908-1F65-CC9B-416C-CCFABE4221B9' )
                  DECLARE @DefinedTypeId int = ( SELECT TOP 1 [Id] FROM [DefinedType] WHERE[Guid] = 'BCBE1494-23F5-3683-4EC5-C0B5CACE8A5A' )

                  IF NOT EXISTS (
		                SELECT *
		                FROM AttributeQualifier
		                WHERE [AttributeId] = @AttributeId
                        AND [Key] = 'definedtype'
		                )
                  BEGIN                  
                        INSERT INTO [AttributeQualifier]
                            ([IsSystem], [AttributeId], [Key], [Value], [Guid])
                            VALUES
                            ( 0, @AttributeId, 'definedtype', @DefinedTypeId, newid() )
                  END");

            // group attribute of category
            RockMigrationHelper.AddGroupTypeGroupAttribute("D1D95777-FFA3-CBB3-4A6D-658706DAED33", SystemGuid.FieldType.CATEGORY, "Category", "The category for the communication list.", 0, "", "E3810936-182E-2585-4F8E-030A0E18B27A");
            RockMigrationHelper.AddAttributeQualifier("E3810936-182E-2585-4F8E-030A0E18B27A", "entityTypeName", "Rock.Model.Group", "20AA23EC-B732-B2A8-444E-60CA6FB3C986");
            RockMigrationHelper.AddAttributeQualifier("E3810936-182E-2585-4F8E-030A0E18B27A", "qualifierColumn", "GroupTypeId", "0DFD7DA3-1B68-9E9B-43D6-C415753D6718");
            Sql(@"DECLARE @AttributeId int = (SELECT TOP 1 [Id] FROM [Attribute] WHERE [Guid] = 'E3810936-182E-2585-4F8E-030A0E18B27A' )
                  DECLARE @GroupTypeId int = ( SELECT TOP 1 [Id] FROM [GroupType] WHERE[Guid] = 'D1D95777-FFA3-CBB3-4A6D-658706DAED33' )

                  INSERT INTO[AttributeQualifier]
                  ([IsSystem], [AttributeId], [Key], [Value], [Guid])
                  VALUES
                  ( 0, @AttributeId, 'qualifierValue', @GroupTypeId, newid() )");


            // pages
            RockMigrationHelper.AddPage("199DC522-F4D6-4D82-AF44-3C16EE9D2CDA", "D65F783D-87A9-4CC9-8110-E83466A0EADB", "Communication List Categories", "", "307570FD-9472-48D5-A67F-80B2056C5308", "fa fa-folder"); // Site:Rock RMS
            RockMigrationHelper.AddPage("199DC522-F4D6-4D82-AF44-3C16EE9D2CDA", "D65F783D-87A9-4CC9-8110-E83466A0EADB", "Communication Lists", "", "002C9991-523A-478C-B19B-E9DF2B977481", "fa fa-bullhorn");         // Site:Rock RMS
            RockMigrationHelper.AddPage("002C9991-523A-478C-B19B-E9DF2B977481", "D65F783D-87A9-4CC9-8110-E83466A0EADB", "Communication List Detail", "", "60216406-5BD6-4253-B891-262717C07A00", "fa fa-bullhorn");   // Site:Rock RMS
            RockMigrationHelper.AddPage("60216406-5BD6-4253-B891-262717C07A00", "D65F783D-87A9-4CC9-8110-E83466A0EADB", "Group Member Detail", "", "FB3FCA8D-2011-42B5-A9F4-2657C4F856AC", "");                       // Site:Rock RMS

            // Add Block to Page: Communication List Categories, Site: Rock RMS
            RockMigrationHelper.AddBlock("307570FD-9472-48D5-A67F-80B2056C5308", "", "620FC4A2-6587-409F-8972-22065919D9AC", "Categories", "Main", "", "", 0, "25F82ADE-BD0A-404C-A659-30874AFC50A1");
            // Add Block to Page: Communication Lists, Site: Rock RMS
            RockMigrationHelper.AddBlock("002C9991-523A-478C-B19B-E9DF2B977481", "", "3D7FB6BE-6BBD-49F7-96B4-96310AF3048A", "Group List", "Main", "", "", 0, "426EC86B-5784-411D-94ED-DD007E6DF783");
            // Add Block to Page: Communication List Detail, Site: Rock RMS
            RockMigrationHelper.AddBlock("60216406-5BD6-4253-B891-262717C07A00", "", "582BEEA1-5B27-444D-BC0A-F60CEB053981", "Group Detail", "Main", "", "", 0, "3FF79A87-ABC1-4DE3-B25A-8111E5D05607");
            // Add Block to Page: Communication List Detail, Site: Rock RMS
            RockMigrationHelper.AddBlock("60216406-5BD6-4253-B891-262717C07A00", "", "88B7EFA9-7419-4D05-9F88-38B936E61EDD", "Group Member List", "Main", "", "", 1, "B906C477-BFA2-4617-BCE4-B7A1D3D8042C");
            // Add Block to Page: Group Member Detail, Site: Rock RMS
            RockMigrationHelper.AddBlock("FB3FCA8D-2011-42B5-A9F4-2657C4F856AC", "", "AAE2E5C3-9279-4AB0-9682-F4D19519D678", "Group Member Detail", "Main", "", "", 0, "550684A1-D34C-4198-B87E-5BC5C644A920");
            // update block order for pages with new blocks if the page,zone has multiple blocks
            Sql(@"UPDATE [Block] SET [Order] = 0 WHERE [Guid] = '3FF79A87-ABC1-4DE3-B25A-8111E5D05607'");    // Page: Communication List Detail,  Zone: Main,  Block: Group Detail
            Sql(@"UPDATE [Block] SET [Order] = 0 WHERE [Guid] = '3FF79A87-ABC1-4DE3-B25A-8111E5D05607'");    // Page: Communication List Detail,  Zone: Main,  Block: Group Detail
            Sql(@"UPDATE [Block] SET [Order] = 1 WHERE [Guid] = 'B906C477-BFA2-4617-BCE4-B7A1D3D8042C'");    // Page: Communication List Detail,  Zone: Main,  Block: Group Member List
            Sql(@"UPDATE [Block] SET [Order] = 1 WHERE [Guid] = 'B906C477-BFA2-4617-BCE4-B7A1D3D8042C'");    // Page: Communication List Detail,  Zone: Main,  Block: Group Member List


            // Attrib Value for Block:Categories, Attribute:Entity Type Page: Communication List Categories, Site: Rock RMS
            RockMigrationHelper.AddBlockAttributeValue("25F82ADE-BD0A-404C-A659-30874AFC50A1", "C405A507-7889-4287-8342-105B89710044", @"9bbfda11-0d22-40d5-902f-60adfbc88987");
            // Attrib Value for Block:Categories, Attribute:Enable Hierarchy Page: Communication List Categories, Site: Rock RMS
            RockMigrationHelper.AddBlockAttributeValue("25F82ADE-BD0A-404C-A659-30874AFC50A1", "F3370A76-E1D1-47FD-AE90-1D428183235C", @"True");
            // Attrib Value for Block:Categories, Attribute:Entity Qualifier Column Page: Communication List Categories, Site: Rock RMS
            RockMigrationHelper.AddBlockAttributeValue("25F82ADE-BD0A-404C-A659-30874AFC50A1", "E9E2BE91-5D5E-4688-A6AD-A4AAD3D629E2", @"GroupTypeId");
            // Attrib Value for Block:Categories, Attribute:Entity Qualifier Value Page: Communication List Categories, Site: Rock RMS
            RockMigrationHelper.AddBlockAttributeValue("25F82ADE-BD0A-404C-A659-30874AFC50A1", "E3CC4A91-697C-4269-8AA8-E1F1A63F04D8", @"31");
            // Attrib Value for Block:Group List, Attribute:Display Member Count Column Page: Communication Lists, Site: Rock RMS
            RockMigrationHelper.AddBlockAttributeValue("426EC86B-5784-411D-94ED-DD007E6DF783", "FDD84597-E3E8-4E91-A72F-C6538B085310", @"True");
            // Attrib Value for Block:Group List, Attribute:Limit to Active Status Page: Communication Lists, Site: Rock RMS
            RockMigrationHelper.AddBlockAttributeValue("426EC86B-5784-411D-94ED-DD007E6DF783", "B4133552-42B6-4053-90B9-33B882B72D2D", @"all");
            // Attrib Value for Block:Group List, Attribute:Display Group Path Page: Communication Lists, Site: Rock RMS
            RockMigrationHelper.AddBlockAttributeValue("426EC86B-5784-411D-94ED-DD007E6DF783", "6F229535-B44E-44C2-A9AF-28244600E244", @"False");
            // Attrib Value for Block:Group List, Attribute:Display Filter Page: Communication Lists, Site: Rock RMS
            RockMigrationHelper.AddBlockAttributeValue("426EC86B-5784-411D-94ED-DD007E6DF783", "7E0EDF09-9374-4AC4-8591-30C08D7F1E1F", @"True");
            // Attrib Value for Block:Group List, Attribute:Include Group Types Page: Communication Lists, Site: Rock RMS
            RockMigrationHelper.AddBlockAttributeValue("426EC86B-5784-411D-94ED-DD007E6DF783", "5164FF88-A53B-4982-BE50-D56F1FE13FC6", @"d1d95777-ffa3-cbb3-4a6d-658706daed33");
            // Attrib Value for Block:Group List, Attribute:Exclude Group Types Page: Communication Lists, Site: Rock RMS
            RockMigrationHelper.AddBlockAttributeValue("426EC86B-5784-411D-94ED-DD007E6DF783", "0901CBFE-1980-4A1C-8AF0-4A8BD0FC46E9", @"");
            // Attrib Value for Block:Group List, Attribute:Display Group Type Column Page: Communication Lists, Site: Rock RMS
            RockMigrationHelper.AddBlockAttributeValue("426EC86B-5784-411D-94ED-DD007E6DF783", "951D268A-B2A8-42A2-B1C1-3B854070DDF9", @"False");
            // Attrib Value for Block:Group List, Attribute:Display Description Column Page: Communication Lists, Site: Rock RMS
            RockMigrationHelper.AddBlockAttributeValue("426EC86B-5784-411D-94ED-DD007E6DF783", "A0E1B2A4-9D86-4F57-B608-FC7CC498EAC3", @"True");
            // Attrib Value for Block:Group List, Attribute:Limit to Security Role Groups Page: Communication Lists, Site: Rock RMS
            RockMigrationHelper.AddBlockAttributeValue("426EC86B-5784-411D-94ED-DD007E6DF783", "1DAD66E3-8859-487E-8200-483C98DE2E07", @"False");
            // Attrib Value for Block:Group List, Attribute:Detail Page Page: Communication Lists, Site: Rock RMS
            RockMigrationHelper.AddBlockAttributeValue("426EC86B-5784-411D-94ED-DD007E6DF783", "8E57EC42-ABEE-4D35-B7FA-D8513880E8E4", @"60216406-5bd6-4253-b891-262717c07a00");
            // Attrib Value for Block:Group List, Attribute:Display System Column Page: Communication Lists, Site: Rock RMS
            RockMigrationHelper.AddBlockAttributeValue("426EC86B-5784-411D-94ED-DD007E6DF783", "766A4BFA-D2D1-4744-B30D-637A7E3B9D8F", @"False");
            // Attrib Value for Block:Group List, Attribute:Display Active Status Column Page: Communication Lists, Site: Rock RMS
            RockMigrationHelper.AddBlockAttributeValue("426EC86B-5784-411D-94ED-DD007E6DF783", "FCB5F8B3-9C0E-46A8-974A-15353447FCD7", @"True");
            // Attrib Value for Block:Group Detail, Attribute:Group Map Page Page: Communication List Detail, Site: Rock RMS
            RockMigrationHelper.AddBlockAttributeValue("3FF79A87-ABC1-4DE3-B25A-8111E5D05607", "69F9C989-456D-4855-A420-050DB8B9FEB7", @"");
            // Attrib Value for Block:Group Detail, Attribute:Map Style Page: Communication List Detail, Site: Rock RMS
            RockMigrationHelper.AddBlockAttributeValue("3FF79A87-ABC1-4DE3-B25A-8111E5D05607", "E50B6C24-930C-4D9C-BD94-0AD6BC018C4D", @"fdc5d6ba-a818-4a06-96b1-9ef31b4087ac");
            // Attrib Value for Block:Group Detail, Attribute:Group Types Exclude Page: Communication List Detail, Site: Rock RMS
            RockMigrationHelper.AddBlockAttributeValue("3FF79A87-ABC1-4DE3-B25A-8111E5D05607", "85EE581F-D246-498A-B857-5AD33EC3CAEA", @"");
            // Attrib Value for Block:Group Detail, Attribute:Registration Instance Page Page: Communication List Detail, Site: Rock RMS
            RockMigrationHelper.AddBlockAttributeValue("3FF79A87-ABC1-4DE3-B25A-8111E5D05607", "36643FFE-C49F-443E-8C3D-E83324A45822", @"844dc54b-daec-47b3-a63a-712dd6d57793");
            // Attrib Value for Block:Group Detail, Attribute:Event Item Occurrence Page Page: Communication List Detail, Site: Rock RMS
            RockMigrationHelper.AddBlockAttributeValue("3FF79A87-ABC1-4DE3-B25A-8111E5D05607", "6114CE99-C97F-4394-93F5-B34D479AB54E", @"4b0c44ee-28e3-4753-a95b-8c57cd958fd1");
            // Attrib Value for Block:Group Detail, Attribute:Content Item Page Page: Communication List Detail, Site: Rock RMS
            RockMigrationHelper.AddBlockAttributeValue("3FF79A87-ABC1-4DE3-B25A-8111E5D05607", "45897721-F38C-4B4B-BCF9-A81D27DBB731", @"d18e837c-9e65-4a38-8647-dff04a595d97");
            // Attrib Value for Block:Group Detail, Attribute:Show Edit Page: Communication List Detail, Site: Rock RMS
            RockMigrationHelper.AddBlockAttributeValue("3FF79A87-ABC1-4DE3-B25A-8111E5D05607", "50C7E223-459E-4A1C-AE3C-2892CBD40D22", @"True");

            // Attrib Value for Block:Group Detail, Attribute:Group Types Include Page: Communication List Detail, Site: Rock RMS
            RockMigrationHelper.AddBlockAttributeValue("3FF79A87-ABC1-4DE3-B25A-8111E5D05607", "15AC7A62-7BF2-44B7-93CD-EA8F96BF529A", @"d1d95777-ffa3-cbb3-4a6d-658706daed33");

            // Attrib Value for Block:Group Detail, Attribute:Limit to Security Role Groups Page: Communication List Detail, Site: Rock RMS
            RockMigrationHelper.AddBlockAttributeValue("3FF79A87-ABC1-4DE3-B25A-8111E5D05607", "12295C7E-08F4-4AC5-8A34-C829620FC0B1", @"False");
            // Attrib Value for Block:Group Detail, Attribute:Limit to Group Types that are shown in navigation Page: Communication List Detail, Site: Rock RMS
            RockMigrationHelper.AddBlockAttributeValue("3FF79A87-ABC1-4DE3-B25A-8111E5D05607", "62B0099E-B1A3-4468-B821-B96AB088A861", @"False");
            // Attrib Value for Block:Group Member List, Attribute:Detail Page Page: Communication List Detail, Site: Rock RMS
            RockMigrationHelper.AddBlockAttributeValue("B906C477-BFA2-4617-BCE4-B7A1D3D8042C", "E4CCB79C-479F-4BEE-8156-969B2CE05973", @"fb3fca8d-2011-42b5-a9f4-2657c4f856ac");
            // Attrib Value for Block:Group Member List, Attribute:Person Profile Page Page: Communication List Detail, Site: Rock RMS
            RockMigrationHelper.AddBlockAttributeValue("B906C477-BFA2-4617-BCE4-B7A1D3D8042C", "9E139BB9-D87C-4C9F-A241-DC4620AD340B", @"08dbd8a5-2c35-4146-b4a8-0f7652348b25");
            // Attrib Value for Block:Group Member List, Attribute:Registration Page Page: Communication List Detail, Site: Rock RMS
            RockMigrationHelper.AddBlockAttributeValue("B906C477-BFA2-4617-BCE4-B7A1D3D8042C", "EDF79295-04A4-42B4-B382-DDEF5888D565", @"fc81099a-2f98-4eba-ac5a-8300b2fe46c4");
            // Attrib Value for Block:Group Member List, Attribute:Show Campus Filter Page: Communication List Detail, Site: Rock RMS
            RockMigrationHelper.AddBlockAttributeValue("B906C477-BFA2-4617-BCE4-B7A1D3D8042C", "5796D8C1-0F65-48C2-8920-8C9521E974FF", @"True");
            // Attrib Value for Block:Group Member List, Attribute:Show First/Last Attendance Page: Communication List Detail, Site: Rock RMS
            RockMigrationHelper.AddBlockAttributeValue("B906C477-BFA2-4617-BCE4-B7A1D3D8042C", "3BFE216F-9CAC-42FF-AC62-427557351F31", @"False");
            // Attrib Value for Block:Group Member List, Attribute:Show Date Added Page: Communication List Detail, Site: Rock RMS
            RockMigrationHelper.AddBlockAttributeValue("B906C477-BFA2-4617-BCE4-B7A1D3D8042C", "7BC3F3B7-8354-4B1C-B8F8-DEDEC5D8A0BD", @"False");

            RockMigrationHelper.UpdateCategory(Rock.SystemGuid.EntityType.DATAVIEW, "Communication Segments", string.Empty, "Dataviews that can be used to refine a communication recipient list when creating a communication", "FF7081F8-7223-43D4-BE28-CB030DC4E13B");

            // Create [GroupAll] DataViewFilter for DataView: 35 and older
            Sql(@"
IF NOT EXISTS (SELECT * FROM DataViewFilter where [Guid] = '6D8E0255-2BEE-4E7F-AD79-1A224E07D5AF') BEGIN    
    DECLARE
        @ParentDataViewFilterId int = (select Id from DataViewFilter where [Guid] = '00000000-0000-0000-0000-000000000000'),
        @DataViewFilterEntityTypeId int = (select Id from EntityType where [Guid] = '00000000-0000-0000-0000-000000000000')

    INSERT INTO [DataViewFilter] (ExpressionType, ParentId, EntityTypeId, Selection, [Guid]) 
    values (1,@ParentDataViewFilterId,@DataViewFilterEntityTypeId,'','6D8E0255-2BEE-4E7F-AD79-1A224E07D5AF')
END
");
            // Create Rock.Reporting.DataFilter.Person.AgeFilter DataViewFilter for DataView: 35 and older
            /* NOTE to Developer. Review that the generated DataViewFilter.Selection '256|35|,' for Rock.Reporting.DataFilter.Person.AgeFilter will work on different databases */
            Sql(@"
IF NOT EXISTS (SELECT * FROM DataViewFilter where [Guid] = '90563175-E8C6-4845-9D60-78C0BBD5A9BE') BEGIN    
    DECLARE
        @ParentDataViewFilterId int = (select Id from DataViewFilter where [Guid] = '6D8E0255-2BEE-4E7F-AD79-1A224E07D5AF'),
        @DataViewFilterEntityTypeId int = (select Id from EntityType where [Guid] = '4911C63D-71BB-4686-AAA3-D66EA41DA465')

    INSERT INTO [DataViewFilter] (ExpressionType, ParentId, EntityTypeId, Selection, [Guid]) 
    values (0,@ParentDataViewFilterId,@DataViewFilterEntityTypeId,'256|35|,','90563175-E8C6-4845-9D60-78C0BBD5A9BE')
END
");
            // Create DataView: 35 and older
            Sql(@"
IF NOT EXISTS (SELECT * FROM DataView where [Guid] = '5537D54C-1B9B-4B81-AA63-F10D676FAE77') BEGIN
DECLARE
    @categoryId int = (select top 1 [Id] from [Category] where [Guid] = 'FF7081F8-7223-43D4-BE28-CB030DC4E13B'),
    @entityTypeId  int = (select top 1 [Id] from [EntityType] where [Guid] = '72657ED8-D16E-492E-AC12-144C5E7567E7'),
    @dataViewFilterId  int = (select top 1 [Id] from [DataViewFilter] where [Guid] = '6D8E0255-2BEE-4E7F-AD79-1A224E07D5AF'),
    @transformEntityTypeId  int = (select top 1 [Id] from [EntityType] where [Guid] = '00000000-0000-0000-0000-000000000000')

INSERT INTO [DataView] ([IsSystem], [Name], [Description], [CategoryId], [EntityTypeId], [DataViewFilterId], [TransformEntityTypeId], [Guid])
VALUES(0,'35 and older','A filter to help refine a communications recipient list to include only people that are 35 and older',@categoryId,@entityTypeId,@dataViewFilterId,@transformEntityTypeId,'5537D54C-1B9B-4B81-AA63-F10D676FAE77')
END
");

            // Create [GroupAll] DataViewFilter for DataView: Female
            Sql(@"
IF NOT EXISTS (SELECT * FROM DataViewFilter where [Guid] = '01CDD06D-810E-4861-85EE-69FB8C97EA3C') BEGIN    
    DECLARE
        @ParentDataViewFilterId int = (select Id from DataViewFilter where [Guid] = '00000000-0000-0000-0000-000000000000'),
        @DataViewFilterEntityTypeId int = (select Id from EntityType where [Guid] = '00000000-0000-0000-0000-000000000000')

    INSERT INTO [DataViewFilter] (ExpressionType, ParentId, EntityTypeId, Selection, [Guid]) 
    values (1,@ParentDataViewFilterId,@DataViewFilterEntityTypeId,'','01CDD06D-810E-4861-85EE-69FB8C97EA3C')
END
");
            // Create Rock.Reporting.DataFilter.PropertyFilter DataViewFilter for DataView: Female

            /* NOTE to Developer. Review that the generated DataViewFilter.Selection '[
             * "Property_Gender",
             * "Female"
             * ]' for Rock.Reporting.DataFilter.PropertyFilter will work on different databases */
            Sql(@"
IF NOT EXISTS (SELECT * FROM DataViewFilter where [Guid] = 'CD9ADB66-67E5-4F3E-A481-13EE257407EC') BEGIN    
    DECLARE
        @ParentDataViewFilterId int = (select Id from DataViewFilter where [Guid] = '01CDD06D-810E-4861-85EE-69FB8C97EA3C'),
        @DataViewFilterEntityTypeId int = (select Id from EntityType where [Guid] = '03F0D6AC-D181-48B6-B4BC-1F2652B55323')

    INSERT INTO [DataViewFilter] (ExpressionType, ParentId, EntityTypeId, Selection, [Guid]) 
    values (0,@ParentDataViewFilterId,@DataViewFilterEntityTypeId,'[
  ""Property_Gender"",
  ""Female""
]','CD9ADB66-67E5-4F3E-A481-13EE257407EC')
END
");
            // Create DataView: Female
            Sql(@"
IF NOT EXISTS (SELECT * FROM DataView where [Guid] = 'E2CC2258-BF35-4DB2-91E2-9BE1B68156A3') BEGIN
DECLARE
    @categoryId int = (select top 1 [Id] from [Category] where [Guid] = 'FF7081F8-7223-43D4-BE28-CB030DC4E13B'),
    @entityTypeId  int = (select top 1 [Id] from [EntityType] where [Guid] = '72657ED8-D16E-492E-AC12-144C5E7567E7'),
    @dataViewFilterId  int = (select top 1 [Id] from [DataViewFilter] where [Guid] = '01CDD06D-810E-4861-85EE-69FB8C97EA3C'),
    @transformEntityTypeId  int = (select top 1 [Id] from [EntityType] where [Guid] = '00000000-0000-0000-0000-000000000000')

INSERT INTO [DataView] ([IsSystem], [Name], [Description], [CategoryId], [EntityTypeId], [DataViewFilterId], [TransformEntityTypeId], [Guid])
VALUES(0,'Female','A filter to help refine a communications recipient list to include only females',@categoryId,@entityTypeId,@dataViewFilterId,@transformEntityTypeId,'E2CC2258-BF35-4DB2-91E2-9BE1B68156A3')
END
");

            // Create [GroupAll] DataViewFilter for DataView: Male
            Sql(@"
IF NOT EXISTS (SELECT * FROM DataViewFilter where [Guid] = '348FF1A5-2D80-4FC6-86AF-0FC3C117982A') BEGIN    
    DECLARE
        @ParentDataViewFilterId int = (select Id from DataViewFilter where [Guid] = '00000000-0000-0000-0000-000000000000'),
        @DataViewFilterEntityTypeId int = (select Id from EntityType where [Guid] = '00000000-0000-0000-0000-000000000000')

    INSERT INTO [DataViewFilter] (ExpressionType, ParentId, EntityTypeId, Selection, [Guid]) 
    values (1,@ParentDataViewFilterId,@DataViewFilterEntityTypeId,'','348FF1A5-2D80-4FC6-86AF-0FC3C117982A')
END
");
            // Create Rock.Reporting.DataFilter.PropertyFilter DataViewFilter for DataView: Male

            /* NOTE to Developer. Review that the generated DataViewFilter.Selection '[
             * "Property_Gender",
             * "Male"
             * ]' for Rock.Reporting.DataFilter.PropertyFilter will work on different databases */
            Sql(@"
IF NOT EXISTS (SELECT * FROM DataViewFilter where [Guid] = '03D9CA62-4F58-43C6-A508-AE8597B27539') BEGIN    
    DECLARE
        @ParentDataViewFilterId int = (select Id from DataViewFilter where [Guid] = '348FF1A5-2D80-4FC6-86AF-0FC3C117982A'),
        @DataViewFilterEntityTypeId int = (select Id from EntityType where [Guid] = '03F0D6AC-D181-48B6-B4BC-1F2652B55323')

    INSERT INTO [DataViewFilter] (ExpressionType, ParentId, EntityTypeId, Selection, [Guid]) 
    values (0,@ParentDataViewFilterId,@DataViewFilterEntityTypeId,'[
  ""Property_Gender"",
  ""Male""
]','03D9CA62-4F58-43C6-A508-AE8597B27539')
END
");
            // Create DataView: Male
            Sql(@"
IF NOT EXISTS (SELECT * FROM DataView where [Guid] = 'C43983D7-1F22-4E94-9F5C-342DA3A0E168') BEGIN
DECLARE
    @categoryId int = (select top 1 [Id] from [Category] where [Guid] = 'FF7081F8-7223-43D4-BE28-CB030DC4E13B'),
    @entityTypeId  int = (select top 1 [Id] from [EntityType] where [Guid] = '72657ED8-D16E-492E-AC12-144C5E7567E7'),
    @dataViewFilterId  int = (select top 1 [Id] from [DataViewFilter] where [Guid] = '348FF1A5-2D80-4FC6-86AF-0FC3C117982A'),
    @transformEntityTypeId  int = (select top 1 [Id] from [EntityType] where [Guid] = '00000000-0000-0000-0000-000000000000')

INSERT INTO [DataView] ([IsSystem], [Name], [Description], [CategoryId], [EntityTypeId], [DataViewFilterId], [TransformEntityTypeId], [Guid])
VALUES(0,'Male','A filter to help refine a communications recipient list to include only males',@categoryId,@entityTypeId,@dataViewFilterId,@transformEntityTypeId,'C43983D7-1F22-4E94-9F5C-342DA3A0E168')
END
");

            // Create [GroupAll] DataViewFilter for DataView: Under 35
            Sql(@"
IF NOT EXISTS (SELECT * FROM DataViewFilter where [Guid] = '8760D688-01B9-4030-BF19-898D68CBA757') BEGIN    
    DECLARE
        @ParentDataViewFilterId int = (select Id from DataViewFilter where [Guid] = '00000000-0000-0000-0000-000000000000'),
        @DataViewFilterEntityTypeId int = (select Id from EntityType where [Guid] = '00000000-0000-0000-0000-000000000000')

    INSERT INTO [DataViewFilter] (ExpressionType, ParentId, EntityTypeId, Selection, [Guid]) 
    values (1,@ParentDataViewFilterId,@DataViewFilterEntityTypeId,'','8760D688-01B9-4030-BF19-898D68CBA757')
END
");
            // Create Rock.Reporting.DataFilter.Person.AgeFilter DataViewFilter for DataView: Under 35
            /* NOTE to Developer. Review that the generated DataViewFilter.Selection '512|35|,' for Rock.Reporting.DataFilter.Person.AgeFilter will work on different databases */
            Sql(@"
IF NOT EXISTS (SELECT * FROM DataViewFilter where [Guid] = '9423C06E-C5D3-4589-8EA7-813A6F59F13B') BEGIN    
    DECLARE
        @ParentDataViewFilterId int = (select Id from DataViewFilter where [Guid] = '8760D688-01B9-4030-BF19-898D68CBA757'),
        @DataViewFilterEntityTypeId int = (select Id from EntityType where [Guid] = '4911C63D-71BB-4686-AAA3-D66EA41DA465')

    INSERT INTO [DataViewFilter] (ExpressionType, ParentId, EntityTypeId, Selection, [Guid]) 
    values (0,@ParentDataViewFilterId,@DataViewFilterEntityTypeId,'512|35|,','9423C06E-C5D3-4589-8EA7-813A6F59F13B')
END
");
            // Create DataView: Under 35
            Sql(@"
IF NOT EXISTS (SELECT * FROM DataView where [Guid] = 'FF608842-BB10-4C9C-AA18-9D5C407590D3') BEGIN
DECLARE
    @categoryId int = (select top 1 [Id] from [Category] where [Guid] = 'FF7081F8-7223-43D4-BE28-CB030DC4E13B'),
    @entityTypeId  int = (select top 1 [Id] from [EntityType] where [Guid] = '72657ED8-D16E-492E-AC12-144C5E7567E7'),
    @dataViewFilterId  int = (select top 1 [Id] from [DataViewFilter] where [Guid] = '8760D688-01B9-4030-BF19-898D68CBA757'),
    @transformEntityTypeId  int = (select top 1 [Id] from [EntityType] where [Guid] = '00000000-0000-0000-0000-000000000000')

INSERT INTO [DataView] ([IsSystem], [Name], [Description], [CategoryId], [EntityTypeId], [DataViewFilterId], [TransformEntityTypeId], [Guid])
VALUES(0,'Under 35','A filter to help refine a communications recipient list to include only people that under age of 35',@categoryId,@entityTypeId,@dataViewFilterId,@transformEntityTypeId,'FF608842-BB10-4C9C-AA18-9D5C407590D3')
END
");

            // Job for Migrating Interaction Data
            Sql(@"
    INSERT INTO [dbo].[ServiceJob] ( [IsSystem], [IsActive], [Name], [Description], [Class], [CronExpression], [NotificationStatus] ,[Guid] )
    VALUES ( 0, 1, 'Convert communication medium data', 'Converts communication medium data to field values.', 
        'Rock.Jobs.MigrateCommunicationMediumData', '0 0 3 1/1 * ? *', 3, 'E7C54AAB-451E-4E89-8083-CF398D37416E')");
        }
        public override void Up()
        {
            RockMigrationHelper.AddGroupType("Acme Certificates",
                                             "Contains information on Acme SSL Certificates that are installed and will be renewed.",
                                             "Certificate", "Member", false, false, false, "fa fa-certificate", 999,
                                             null, 0, null, SystemGuid.GroupType.ACME_CERTIFICATES);
            int groupTypeId = ( int )SqlScalar("SELECT [Id] FROM [GroupType] WHERE [Guid] = @Guid", "@Guid", SystemGuid.GroupType.ACME_CERTIFICATES);

            RockMigrationHelper.AddEntityAttribute("Rock.Model.GroupType",
                                                   Rock.SystemGuid.FieldType.TEXT, "Id", groupTypeId.ToString(),
                                                   "Account", string.Empty, string.Empty, 0,
                                                   string.Empty, SystemGuid.Attribute.ACCOUNT);

            RockMigrationHelper.AddGroupTypeGroupAttribute(SystemGuid.GroupType.ACME_CERTIFICATES,
                                                           Rock.SystemGuid.FieldType.TEXT, "Domains", string.Empty,
                                                           0, string.Empty, SystemGuid.Attribute.DOMAINS);

            RockMigrationHelper.AddGroupTypeGroupAttribute(SystemGuid.GroupType.ACME_CERTIFICATES,
                                                           Rock.SystemGuid.FieldType.DATE_TIME, "Last Renewed", string.Empty,
                                                           1, string.Empty, SystemGuid.Attribute.LAST_RENEWED);

            RockMigrationHelper.AddGroupTypeGroupAttribute(SystemGuid.GroupType.ACME_CERTIFICATES,
                                                           Rock.SystemGuid.FieldType.TEXT, "Certificate Hash", string.Empty,
                                                           2, string.Empty, SystemGuid.Attribute.CERTIFICATE_HASH);

            RockMigrationHelper.AddGroupTypeGroupAttribute(SystemGuid.GroupType.ACME_CERTIFICATES,
                                                           Rock.SystemGuid.FieldType.TEXT, "Bindings", string.Empty,
                                                           3, string.Empty, SystemGuid.Attribute.BINDINGS);

            RockMigrationHelper.AddGroupTypeGroupAttribute(SystemGuid.GroupType.ACME_CERTIFICATES,
                                                           Rock.SystemGuid.FieldType.TEXT, "Remove Old Certificate", string.Empty,
                                                           4, string.Empty, SystemGuid.Attribute.REMOVE_OLD_CERTIFICATE);

            RockMigrationHelper.AddBlockType("Acme Config",
                                             "Configures the Acme certification system.",
                                             "~/Plugins/com_blueboxmoon/AcmeCertificate/AcmeConfig.ascx",
                                             "Blue Box Moon > Acme Certificate",
                                             SystemGuid.BlockType.ACME_CONFIG);

            RockMigrationHelper.AddBlockType("Acme Certificates",
                                             "Lists the certificate configuration.",
                                             "~/Plugins/com_blueboxmoon/AcmeCertificate/AcmeCertificates.ascx",
                                             "Blue Box Moon > Acme Certificate",
                                             SystemGuid.BlockType.ACME_CERTIFICATES);

            RockMigrationHelper.AddBlockType("Acme Certificate Detail",
                                             "Configures a certificate.",
                                             "~/Plugins/com_blueboxmoon/AcmeCertificate/AcmeCertificateDetail.ascx",
                                             "Blue Box Moon > Acme Certificate",
                                             SystemGuid.BlockType.ACME_CERTIFICATE_DETAIL);

            RockMigrationHelper.AddBlockType("Acme Challenge",
                                             "Responds to challenges for the Acme certification system.",
                                             "~/Plugins/com_blueboxmoon/AcmeCertificate/AcmeChallenge.ascx",
                                             "Blue Box Moon > Acme Certificate",
                                             SystemGuid.BlockType.ACME_CHALLENGE);

            RockMigrationHelper.AddBlockTypeAttribute(SystemGuid.BlockType.ACME_CERTIFICATES,
                                                      Rock.SystemGuid.FieldType.PAGE_REFERENCE,
                                                      "Detail Page", "DetailPage", string.Empty, string.Empty,
                                                      0, string.Empty, SystemGuid.Attribute.DETAIL_PAGE);

            RockMigrationHelper.AddPage(SystemGuid.Page.ROCK_INSTALLED_PLUGINS,
                                        "D65F783D-87A9-4CC9-8110-E83466A0EADB",
                                        "Acme Certificates",
                                        string.Empty,
                                        SystemGuid.Page.ACME_CERTIFICATES,
                                        "fa fa-certificate");

            RockMigrationHelper.AddPage(SystemGuid.Page.ACME_CERTIFICATES,
                                        "D65F783D-87A9-4CC9-8110-E83466A0EADB",
                                        "Acme Certificate Detail",
                                        string.Empty,
                                        SystemGuid.Page.ACME_CERTIFICATE_DETAIL,
                                        "fa fa-certificate");

            RockMigrationHelper.AddPage(SystemGuid.Page.ACME_CERTIFICATES,
                                        "D65F783D-87A9-4CC9-8110-E83466A0EADB",
                                        "Acme Challenge",
                                        string.Empty,
                                        SystemGuid.Page.ACME_CERTIFICATE_CHALLENGE);
            RockMigrationHelper.AddPageRoute(SystemGuid.Page.ACME_CERTIFICATE_CHALLENGE, ".well-known/acme-challenge/{Token}");

            RockMigrationHelper.AddBlock(SystemGuid.Page.ACME_CERTIFICATES,
                                         string.Empty, SystemGuid.BlockType.ACME_CONFIG,
                                         "Acme Config", "Main", string.Empty, string.Empty, 0, SystemGuid.Block.ACME_CONFIG);

            RockMigrationHelper.AddBlock(SystemGuid.Page.ACME_CERTIFICATES,
                                         string.Empty, SystemGuid.BlockType.ACME_CERTIFICATES,
                                         "Acme Certificates", "Main", string.Empty, string.Empty, 1, SystemGuid.Block.ACME_CERTIFICATES);

            RockMigrationHelper.AddBlock(SystemGuid.Page.ACME_CERTIFICATE_DETAIL,
                                         string.Empty, SystemGuid.BlockType.ACME_CERTIFICATE_DETAIL,
                                         "Acme Certificate Details", "Main", string.Empty, string.Empty, 0, SystemGuid.Block.ACME_CERTIFICATE_DETAIL);

            RockMigrationHelper.AddBlock(SystemGuid.Page.ACME_CERTIFICATE_CHALLENGE,
                                         string.Empty, SystemGuid.BlockType.ACME_CHALLENGE,
                                         "Acme Challenge", "Main", string.Empty, string.Empty, 0, SystemGuid.Block.ACME_CHALLENGE);

            RockMigrationHelper.AddBlockAttributeValue(SystemGuid.Block.ACME_CERTIFICATES,
                                                       SystemGuid.Attribute.DETAIL_PAGE, SystemGuid.Page.ACME_CERTIFICATE_DETAIL);
        }
 public override void Up()
 {
     RockMigrationHelper.AddGroupTypeGroupAttribute(SystemGuid.GroupType.ACME_CERTIFICATES,
                                                    Rock.SystemGuid.FieldType.DATE_TIME, "Expires", string.Empty,
                                                    5, string.Empty, SystemGuid.Attribute.CERTIFICATE_EXPIRES);
 }
        /// <summary>
        /// The commands to run to migrate plugin to the specific version
        /// </summary>
        public override void Up()
        {
            var migrateNamespace = false;
            var oldNamespace     = "com.kfs.GroupRSVP";

            // check if migration has previously run
            using (var rockContext = new RockContext())
            {
                var migrationNumber = (System.Attribute.GetCustomAttribute(this.GetType(), typeof(MigrationNumberAttribute)) as MigrationNumberAttribute).Number;
                migrateNamespace = new PluginMigrationService(rockContext)
                                   .Queryable()
                                   .Where(m => m.PluginAssemblyName.Equals(oldNamespace, StringComparison.CurrentCultureIgnoreCase) && m.MigrationNumber == migrationNumber)
                                   .Any();
            }

            if (migrateNamespace)
            {
                UpdateBlockTypeByGuid("RSVP Group Registration", "Allows a person to register for an RSVP Group.", "~/Plugins/rocks_kfs/RsvpGroups/RsvpGroupRegistration.ascx", "KFS > RSVP Groups", "F7B249C3-7FFD-483D-820F-A44D04E2BAB1");
                UpdateBlockTypeByGuid("Group List Lava", "Lists groups for lava display.", "~/Plugins/rocks_kfs/Groups/GroupListLava.ascx", "KFS > Groups", "6731AF9D-F3CB-4CCB-AA42-19C9CB15CBF5");   // shared block type
            }
            else
            {
                // group type
                RockMigrationHelper.AddGroupType("RSVP Group", "A group that can be used to manage RSVP counts for the group members.", "Group", "Member", false, true, true, "fa fa-clipboard-list", 0, "", 0, "", "1A082EFF-30DA-44B2-8E48-02385C20828E", true);

                // group type role
                RockMigrationHelper.AddGroupTypeRole("1A082EFF-30DA-44B2-8E48-02385C20828E", "Member", "", 0, null, null, "60E0B95A-04D3-4839-917B-6BDAF9808EB5", true, false, true);

                // max rsvp
                RockMigrationHelper.AddGroupTypeGroupAttribute("1A082EFF-30DA-44B2-8E48-02385C20828E", Rock.SystemGuid.FieldType.INTEGER, "Max RSVP", "The RSVP limit for this group. '0' is unlimited.", 0, "", "AE34AFA5-8CB0-4BDA-8ACB-BAB661803BDC", true);

                // send email
                RockMigrationHelper.AddGroupTypeGroupAttribute("1A082EFF-30DA-44B2-8E48-02385C20828E", Rock.SystemGuid.FieldType.BOOLEAN, "Send Email", "Flag indicating if the group email should be sent when someone joins this group.", 1, "False", "9B67F3BF-5F7A-4A9E-A352-67F3D515F63A", true);

                // from email
                RockMigrationHelper.AddGroupTypeGroupAttribute("1A082EFF-30DA-44B2-8E48-02385C20828E", Rock.SystemGuid.FieldType.EMAIL, "From Email", "", 2, "", "6F8FB284-4CCB-45C1-A99E-F8ADA93856B1");

                // from name
                RockMigrationHelper.AddGroupTypeGroupAttribute("1A082EFF-30DA-44B2-8E48-02385C20828E", Rock.SystemGuid.FieldType.TEXT, "From Name", "", 3, "", "9BBE3207-1939-45E3-8A26-6519045E8EA9");
                RockMigrationHelper.AddAttributeQualifier("9BBE3207-1939-45E3-8A26-6519045E8EA9", "ispassword", "false", "8F791A08-72BC-482E-8FBC-8F6463C9669E");

                // subject
                RockMigrationHelper.AddGroupTypeGroupAttribute("1A082EFF-30DA-44B2-8E48-02385C20828E", Rock.SystemGuid.FieldType.TEXT, "Subject", "", 4, "", "C0AD8B37-4D7F-4C17-9B4E-1E8D4352E22D");
                RockMigrationHelper.AddAttributeQualifier("C0AD8B37-4D7F-4C17-9B4E-1E8D4352E22D", "ispassword", "false", "7284B714-AF12-440C-91FE-C4850F0D75F8");

                // message
                RockMigrationHelper.AddGroupTypeGroupAttribute("1A082EFF-30DA-44B2-8E48-02385C20828E", Rock.SystemGuid.FieldType.HTML, "Message", "", 5, "", "7DCB5A58-1FD2-4261-9483-EA65A97151CD");
                RockMigrationHelper.AddAttributeQualifier("7DCB5A58-1FD2-4261-9483-EA65A97151CD", "documentfolderroot", "", "B3C8C1C5-2DEB-49DA-87A8-8B87D48C9ED2");
                RockMigrationHelper.AddAttributeQualifier("7DCB5A58-1FD2-4261-9483-EA65A97151CD", "imagefolderroot", "", "C5CA6A49-E7A7-45AA-B9F4-85F8F6FA8B5D");
                RockMigrationHelper.AddAttributeQualifier("7DCB5A58-1FD2-4261-9483-EA65A97151CD", "toolbar", "Light", "242E3FFC-0680-494F-9EA3-55E8BEF11477");
                RockMigrationHelper.AddAttributeQualifier("7DCB5A58-1FD2-4261-9483-EA65A97151CD", "userspecificroot", "False", "A59A34A7-0EA8-414C-A78F-034FFE954768");

                // member rsvp
                RockMigrationHelper.AddGroupTypeGroupMemberAttribute("1A082EFF-30DA-44B2-8E48-02385C20828E", Rock.SystemGuid.FieldType.INTEGER, "RSVP Count", "", 0, "1", "877D17DD-6303-4863-B87C-F8D05111E835", true);

                // set member rsvp to display in grid, set the association to be self referenced, and set role to view
                Sql(@"
                    DECLARE @GroupMemberRsvpCount INT = (SELECT TOP 1 [Id] FROM [Attribute] WHERE [Guid] = '877D17DD-6303-4863-B87C-F8D05111E835')
                    UPDATE [Attribute]
                    SET [IsGridColumn] = 1
                    WHERE [Id] = @GroupMemberRsvpCount

                    DECLARE @RsvpGroupTypeId INT = (SELECT TOP 1 [Id] FROM [GroupType] WHERE [Guid] = '1A082EFF-30DA-44B2-8E48-02385C20828E')
                    INSERT INTO [GroupTypeAssociation] ( [GroupTypeId], [ChildGroupTypeId] )
                    SELECT @RsvpGroupTypeId, @RsvpGroupTypeId

                    UPDATE [GroupTypeRole]
                    SET [CanView] = 1
                    WHERE [GroupTypeId] = @RsvpGroupTypeId
                ");

                // register blocks
                UpdateBlockTypeByGuid("RSVP Group Registration", "Allows a person to register for an RSVP Group.", "~/Plugins/rocks_kfs/RsvpGroups/RsvpGroupRegistration.ascx", "KFS > RSVP Groups", "F7B249C3-7FFD-483D-820F-A44D04E2BAB1");
                UpdateBlockTypeByGuid("Group List Lava", "Lists groups for lava display.", "~/Plugins/rocks_kfs/Groups/GroupListLava.ascx", "KFS > Groups", "6731AF9D-F3CB-4CCB-AA42-19C9CB15CBF5");   // shared block type
            }
        }