Skip to content

Commit 9f7b544

Browse files
committed
Introduced messaging to help aid in reading the results of the query
1 parent 0747cb7 commit 9f7b544

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

OnTopic.Data.Sql.Database/Scripts/Upgrade from OnTopic 4 to OnTopic 5.sql

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
-- migrations.
1414
--------------------------------------------------------------------------------------------------------------------------------
1515

16+
PRINT('Dropping legacy columns...');
17+
1618
ALTER
1719
TABLE Topics
1820
DROP
@@ -38,6 +40,8 @@ TABLE ExtendedAttributes
3840
DROP
3941
COLUMN DateModified;
4042

43+
PRINT('Dropped legacy columns');
44+
4145
--------------------------------------------------------------------------------------------------------------------------------
4246
-- MIGRATE CORE ATTRIBUTES
4347
--------------------------------------------------------------------------------------------------------------------------------
@@ -46,6 +50,8 @@ COLUMN DateModified;
4650
-- in a way that's inconsistent with other attributes. By moving them to Topic, we better acknowledge their unique status.
4751
--------------------------------------------------------------------------------------------------------------------------------
4852

53+
PRINT('Migrating core attributes...');
54+
4955
ALTER TABLE [dbo].[Topics]
5056
ADD [TopicKey] VARCHAR(128) NULL,
5157
[ContentType] VARCHAR(128) NULL,
@@ -96,6 +102,8 @@ IN ( 'Key',
96102
'ParentID'
97103
)
98104

105+
PRINT('Migrated core attributes');
106+
99107
--------------------------------------------------------------------------------------------------------------------------------
100108
-- MIGRATE TOPIC REFERENCES
101109
--------------------------------------------------------------------------------------------------------------------------------
@@ -105,6 +113,8 @@ IN ( 'Key',
105113
-- service to infer which attributes represent relationships in order to translate their values from `TopicID` to `UniqueKey`.
106114
--------------------------------------------------------------------------------------------------------------------------------
107115

116+
PRINT('Migrating topic references...');
117+
108118
CREATE
109119
TABLE [dbo].[TopicReferences] (
110120
[Source_TopicID] INT NOT NULL,
@@ -124,6 +134,8 @@ WHERE AttributeKey LIKE '%ID'
124134
AND ISNUMERIC(AttributeValue) = 1
125135
AND Topics.TopicID IS NOT NULL
126136

137+
PRINT('Migrated core attributes');
138+
127139
--------------------------------------------------------------------------------------------------------------------------------
128140
-- MIGRATE DERIVED TOPICS
129141
--------------------------------------------------------------------------------------------------------------------------------
@@ -133,6 +145,8 @@ WHERE AttributeKey LIKE '%ID'
133145
-- and how its 'ReferenceKey'.
134146
--------------------------------------------------------------------------------------------------------------------------------
135147

148+
PRINT('Migrating base topics...');
149+
136150
UPDATE TopicReferences
137151
SET ReferenceKey = 'BaseTopic'
138152
WHERE ReferenceKey = 'Topic'
@@ -142,6 +156,8 @@ SET TopicKey = 'BaseTopic'
142156
WHERE TopicKey IN ('TopicID', 'InheritedTopic', 'DerivedTopic')
143157
AND ContentType = 'TopicReferenceAttribute'
144158

159+
PRINT('Migrated base topics');
160+
145161
--------------------------------------------------------------------------------------------------------------------------------
146162
-- MIGRATE ATTRIBUTE KEYS
147163
--------------------------------------------------------------------------------------------------------------------------------
@@ -150,11 +166,15 @@ AND ContentType = 'TopicReferenceAttribute'
150166
-- conflict with .NET's own "*Attribute" convention (which is usually reserved for actual attributes).
151167
--------------------------------------------------------------------------------------------------------------------------------
152168

169+
PRINT('Migrating attribute descriptors...');
170+
153171
UPDATE Topics
154172
SET TopicKey = TopicKey + 'Descriptor'
155173
WHERE TopicKey LIKE '%Attribute'
156174
AND ContentType = 'ContentTypeDescriptor'
157175

158176
UPDATE Topics
159177
SET ContentType = ContentType + 'Descriptor'
160-
WHERE ContentType LIKE '%Attribute'
178+
WHERE ContentType LIKE '%Attribute'
179+
180+
PRINT('Migrated attribute descriptors');

0 commit comments

Comments
 (0)