1313-- migrations.
1414-- ------------------------------------------------------------------------------------------------------------------------------
1515
16+ PRINT (' Dropping legacy columns...' );
17+
1618ALTER
1719TABLE Topics
1820DROP
@@ -38,6 +40,8 @@ TABLE ExtendedAttributes
3840DROP
3941COLUMN 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+
4955ALTER TABLE [dbo].[Topics]
5056ADD [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+
108118CREATE
109119TABLE [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+
136150UPDATE TopicReferences
137151SET ReferenceKey = ' BaseTopic'
138152WHERE ReferenceKey = ' Topic'
@@ -142,6 +156,8 @@ SET TopicKey = 'BaseTopic'
142156WHERE TopicKey IN (' TopicID' , ' InheritedTopic' , ' DerivedTopic' )
143157AND 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+
153171UPDATE Topics
154172SET TopicKey = TopicKey + ' Descriptor'
155173WHERE TopicKey LIKE ' %Attribute'
156174AND ContentType = ' ContentTypeDescriptor'
157175
158176UPDATE Topics
159177SET ContentType = ContentType + ' Descriptor'
160- WHERE ContentType LIKE ' %Attribute'
178+ WHERE ContentType LIKE ' %Attribute'
179+
180+ PRINT (' Migrated attribute descriptors' );
0 commit comments