1+ // <copyright>
2+ // Copyright by the Spark Development Network
3+ //
4+ // Licensed under the Rock Community License (the "License");
5+ // you may not use this file except in compliance with the License.
6+ // You may obtain a copy of the License at
7+ //
8+ // http://www.rockrms.com/license
9+ //
10+ // Unless required by applicable law or agreed to in writing, software
11+ // distributed under the License is distributed on an "AS IS" BASIS,
12+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ // See the License for the specific language governing permissions and
14+ // limitations under the License.
15+ // </copyright>
16+
17+ using System ;
18+
19+ namespace Rock . Plugin . HotFixes
20+ {
21+ /// <summary>
22+ /// Plug-in migration
23+ /// </summary>
24+ /// <seealso cref="Rock.Plugin.Migration" />
25+ [ MigrationNumber ( 252 , "17.1" ) ]
26+ public class MigrationRollupsForV17_2_0 : Migration
27+ {
28+ /// <summary>
29+ /// Operations to be performed during the upgrade process.
30+ /// </summary>
31+ public override void Up ( )
32+ {
33+ UpdateStatusTemplateAttributeUp ( ) ;
34+ }
35+
36+ /// <summary>
37+ /// Operations to be performed during the downgrade process.
38+ /// </summary>
39+ public override void Down ( )
40+ {
41+ // No down
42+ }
43+
44+ #region KH: Update the Default Value for the Status Template Attribute
45+
46+ private void UpdateStatusTemplateAttributeUp ( )
47+ {
48+ var targetAttributeColumn = RockMigrationHelper . NormalizeColumnCRLF ( "DefaultValue" ) ;
49+ var targetAttributeValueColumn = RockMigrationHelper . NormalizeColumnCRLF ( "Value" ) ;
50+
51+ string oldValue = @"<span class='badge badge-danger badge-circle js-legend-badge'>{{ IdleTooltip }}</span>" ;
52+
53+ string newValue = @"<span class='badge badge-danger badge-circle js-legend-badge' data-toggle='tooltip' data-html='true' title='{{IdleTooltipList}}'>{{ IdleTooltip }}</span>" ;
54+
55+ oldValue = oldValue . Replace ( "'" , "''" ) ;
56+ newValue = newValue . Replace ( "'" , "''" ) ;
57+
58+ Sql ( $@ "
59+ DECLARE @BlockEntityTypeId INT = (SELECT [Id] FROM [EntityType] WHERE [Guid] = 'D89555CA-9AE4-4D62-8AF1-E5E463C1EF65')
60+ DECLARE @BlockTypeId INT = (SELECT [Id] FROM [BlockType] WHERE [Guid] = '23438CBC-105B-4ADB-8B9A-D5DDDCDD7643')
61+
62+ UPDATE [Attribute]
63+ SET [DefaultValue] = REPLACE({ targetAttributeColumn } , '{ oldValue } ', '{ newValue } ')
64+ , [DefaultPersistedTextValue] = NULL
65+ , [DefaultPersistedHtmlValue] = NULL
66+ , [DefaultPersistedCondensedTextValue] = NULL
67+ , [DefaultPersistedCondensedHtmlValue] = NULL
68+ , [IsDefaultPersistedValueDirty] = 1
69+ WHERE [EntityTypeId] = @BlockEntityTypeId
70+ AND [EntityTypeQualifierColumn] = 'BlockTypeId'
71+ AND [EntityTypeQualifierValue] = @BlockTypeId
72+ AND [Key] = 'StatusTemplate';
73+
74+ UPDATE [AttributeValue]
75+ SET [Value] = REPLACE({ targetAttributeValueColumn } , '{ oldValue } ', '{ newValue } ')
76+ , [PersistedTextValue] = NULL
77+ , [PersistedHtmlValue] = NULL
78+ , [PersistedCondensedTextValue] = NULL
79+ , [PersistedCondensedHtmlValue] = NULL
80+ , [IsPersistedValueDirty] = 1
81+ WHERE [AttributeId] IN (
82+ SELECT [Id] FROM [Attribute]
83+ WHERE [EntityTypeId] = @BlockEntityTypeId
84+ AND [EntityTypeQualifierColumn] = 'BlockTypeId'
85+ AND [EntityTypeQualifierValue] = @BlockTypeId
86+ AND [Key] = 'StatusTemplate'
87+ )
88+ AND { targetAttributeValueColumn } LIKE '%{ oldValue } %';"
89+ ) ;
90+ }
91+
92+ #endregion
93+ }
94+ }
0 commit comments