PageRenderTime 137ms CodeModel.GetById 100ms app.highlight 31ms RepoModel.GetById 1ms app.codeStats 0ms

/BlogEngine/BlogEngine.NET/setup/SQLServer/MSSQLUpgradeFrom2.0to2.5.sql

#
SQL | 874 lines | 434 code | 143 blank | 297 comment | 0 complexity | 2ddab0349f1f9b9bfe14210b564b7d51 MD5 | raw file
  1
  2
  3SET CONCAT_NULL_YIELDS_NULL, ANSI_NULLS, ANSI_PADDING, QUOTED_IDENTIFIER, ANSI_WARNINGS, ARITHABORT ON
  4SET NUMERIC_ROUNDABORT, IMPLICIT_TRANSACTIONS, XACT_ABORT OFF
  5GO
  6
  7--
  8-- Drop foreign key FK_be_PostCategory_be_Categories on table "be_PostCategory"
  9--
 10ALTER TABLE dbo.be_PostCategory
 11  DROP CONSTRAINT FK_be_PostCategory_be_Categories
 12GO
 13
 14--
 15-- Drop foreign key FK_be_PostCategory_be_Posts on table "be_PostCategory"
 16--
 17ALTER TABLE dbo.be_PostCategory
 18  DROP CONSTRAINT FK_be_PostCategory_be_Posts
 19GO
 20
 21--
 22-- Drop foreign key FK_be_PostComment_be_Posts on table "be_PostComment"
 23--
 24ALTER TABLE dbo.be_PostComment
 25  DROP CONSTRAINT FK_be_PostComment_be_Posts
 26GO
 27
 28--
 29-- Drop foreign key FK_be_PostNotify_be_Posts on table "be_PostNotify"
 30--
 31ALTER TABLE dbo.be_PostNotify
 32  DROP CONSTRAINT FK_be_PostNotify_be_Posts
 33GO
 34
 35--
 36-- Drop foreign key FK_be_PostTag_be_Posts on table "be_PostTag"
 37--
 38ALTER TABLE dbo.be_PostTag
 39  DROP CONSTRAINT FK_be_PostTag_be_Posts
 40GO
 41
 42--
 43-- Create column "BlogID" on table "dbo.be_Users"
 44--
 45ALTER TABLE dbo.be_Users
 46  ADD BlogID uniqueidentifier NULL
 47GO
 48
 49UPDATE dbo.be_Users SET BlogID = '27604F05-86AD-47EF-9E05-950BB762570C'
 50GO
 51
 52ALTER TABLE dbo.be_Users
 53  ALTER
 54    COLUMN BlogID uniqueidentifier NOT NULL
 55GO
 56
 57--
 58-- Create index "idx_be_Users_BlogId_UserName" on table "be_Users"
 59--
 60CREATE INDEX idx_be_Users_BlogId_UserName
 61  ON dbo.be_Users (BlogID, UserName)
 62GO
 63
 64--
 65-- Drop foreign key FK_be_UserRoles_be_Roles on table "be_UserRoles"
 66--
 67ALTER TABLE dbo.be_UserRoles
 68  DROP CONSTRAINT FK_be_UserRoles_be_Roles
 69GO
 70
 71--
 72-- Drop foreign key FK_be_UserRoles_be_Users on table "be_UserRoles"
 73--
 74ALTER TABLE dbo.be_UserRoles
 75  DROP CONSTRAINT FK_be_UserRoles_be_Users
 76GO
 77
 78--
 79-- Create column "BlogID" on table "dbo.be_UserRoles"
 80--
 81ALTER TABLE dbo.be_UserRoles
 82  ADD BlogID uniqueidentifier NULL
 83GO
 84
 85UPDATE dbo.be_UserRoles SET BlogID = '27604F05-86AD-47EF-9E05-950BB762570C'
 86GO
 87
 88ALTER TABLE dbo.be_UserRoles
 89  ALTER
 90    COLUMN BlogID uniqueidentifier NOT NULL
 91GO
 92
 93--
 94-- Create column "UserName" on table "dbo.be_UserRoles"
 95--
 96ALTER TABLE dbo.be_UserRoles
 97  ADD UserName nvarchar(100) NULL
 98GO
 99
100--
101-- Create column "[Role]" on table "dbo.be_UserRoles"
102--
103ALTER TABLE dbo.be_UserRoles
104  ADD [Role] nvarchar(100) NULL
105GO
106
107--
108-- Insert/Lookup values for UserName and Role on table "dbo.be_UserRoles"
109--
110UPDATE dbo.be_UserRoles
111SET [UserName] =
112(
113SELECT [UserName]
114FROM dbo.be_Users
115WHERE dbo.be_Users.[UserID] = dbo.be_UserRoles.[UserID]
116),
117[Role] = 
118(
119SELECT [Role]
120FROM dbo.be_Roles
121WHERE dbo.be_Roles.RoleID = dbo.be_UserRoles.RoleID
122);
123
124ALTER TABLE dbo.be_UserRoles
125  ALTER
126    COLUMN UserName nvarchar(100) NOT NULL
127GO
128
129ALTER TABLE dbo.be_UserRoles
130  ALTER
131    COLUMN [Role] nvarchar(100) NOT NULL
132GO
133
134--
135-- Drop column "UserID" from table "dbo.be_UserRoles"
136--
137ALTER TABLE dbo.be_UserRoles
138  DROP COLUMN UserID
139GO
140
141--
142-- Drop column "RoleID" from table "dbo.be_UserRoles"
143--
144ALTER TABLE dbo.be_UserRoles
145  DROP COLUMN RoleID
146GO
147
148--
149-- Create index "idx_be_UserRoles_BlogId" on table "be_UserRoles"
150--
151CREATE INDEX idx_be_UserRoles_BlogId
152  ON dbo.be_UserRoles (BlogID)
153GO
154
155--
156-- Drop primary key PK_be_StopWords on table "be_StopWords"
157--
158ALTER TABLE dbo.be_StopWords
159  DROP CONSTRAINT PK_be_StopWords
160GO
161
162--
163-- Create column "StopWordRowId" on table "dbo.be_StopWords"
164--
165ALTER TABLE dbo.be_StopWords
166  ADD StopWordRowId int IDENTITY
167GO
168
169--
170-- Create column "BlogId" on table "dbo.be_StopWords"
171--
172ALTER TABLE dbo.be_StopWords
173  ADD BlogId uniqueidentifier NULL
174GO
175
176UPDATE dbo.be_StopWords SET BlogId = '27604F05-86AD-47EF-9E05-950BB762570C'
177GO
178
179ALTER TABLE dbo.be_StopWords
180  ALTER
181    COLUMN BlogId uniqueidentifier NOT NULL
182GO
183
184--
185-- Create primary key PK_be_StopWords on table "be_StopWords"
186--
187ALTER TABLE dbo.be_StopWords
188  ADD CONSTRAINT PK_be_StopWords PRIMARY KEY (StopWordRowId)
189GO
190
191--
192-- Create index "idx_be_StopWords_BlogId" on table "be_StopWords"
193--
194CREATE INDEX idx_be_StopWords_BlogId
195  ON dbo.be_StopWords (BlogId)
196GO
197
198--
199-- Drop primary key PK_be_Settings on table "be_Settings"
200--
201ALTER TABLE dbo.be_Settings
202  DROP CONSTRAINT PK_be_Settings
203GO
204
205--
206-- Create column "SettingRowId" on table "dbo.be_Settings"
207--
208ALTER TABLE dbo.be_Settings
209  ADD SettingRowId int IDENTITY
210GO
211
212--
213-- Create column "BlogId" on table "dbo.be_Settings"
214--
215ALTER TABLE dbo.be_Settings
216  ADD BlogId uniqueidentifier NULL
217GO
218
219UPDATE dbo.be_Settings SET BlogId = '27604F05-86AD-47EF-9E05-950BB762570C'
220GO
221
222ALTER TABLE dbo.be_Settings
223  ALTER
224    COLUMN BlogId uniqueidentifier NOT NULL
225GO
226
227--
228-- Create primary key PK_be_Settings on table "be_Settings"
229--
230ALTER TABLE dbo.be_Settings
231  ADD CONSTRAINT PK_be_Settings PRIMARY KEY (SettingRowId)
232GO
233
234--
235-- Create index "idx_be_Settings_BlogId" on table "be_Settings"
236--
237CREATE INDEX idx_be_Settings_BlogId
238  ON dbo.be_Settings (BlogId)
239GO
240
241--
242-- Create column "BlogID" on table "dbo.be_Roles"
243--
244ALTER TABLE dbo.be_Roles
245  ADD BlogID uniqueidentifier NULL
246GO
247
248UPDATE dbo.be_Roles SET BlogID = '27604F05-86AD-47EF-9E05-950BB762570C'
249GO
250
251ALTER TABLE dbo.be_Roles
252  ALTER
253    COLUMN BlogID uniqueidentifier NOT NULL
254GO
255
256--
257-- Create index "idx_be_Roles_BlogID_Role" on table "be_Roles"
258--
259CREATE UNIQUE INDEX idx_be_Roles_BlogID_Role
260  ON dbo.be_Roles (BlogID, [Role])
261GO
262
263--
264-- Drop primary key PK_be_Rights on table "be_Rights"
265--
266ALTER TABLE dbo.be_Rights
267  DROP CONSTRAINT PK_be_Rights
268GO
269
270--
271-- Create column "RightRowId" on table "dbo.be_Rights"
272--
273ALTER TABLE dbo.be_Rights
274  ADD RightRowId int IDENTITY
275GO
276
277--
278-- Create column "BlogId" on table "dbo.be_Rights"
279--
280ALTER TABLE dbo.be_Rights
281  ADD BlogId uniqueidentifier NULL
282GO
283
284UPDATE dbo.be_Rights SET BlogId = '27604F05-86AD-47EF-9E05-950BB762570C'
285GO
286
287ALTER TABLE dbo.be_Rights
288  ALTER
289    COLUMN BlogId uniqueidentifier NOT NULL
290GO
291
292--
293-- Create primary key PK_be_Rights on table "be_Rights"
294--
295ALTER TABLE dbo.be_Rights
296  ADD CONSTRAINT PK_be_Rights PRIMARY KEY (RightRowId)
297GO
298
299--
300-- Create index "idx_be_Rights_BlogId" on table "be_Rights"
301--
302CREATE INDEX idx_be_Rights_BlogId
303  ON dbo.be_Rights (BlogId)
304GO
305
306--
307-- Drop primary key PK_be_RightRoles on table "be_RightRoles"
308--
309ALTER TABLE dbo.be_RightRoles
310  DROP CONSTRAINT PK_be_RightRoles
311GO
312
313--
314-- Create column "RightRoleRowId" on table "dbo.be_RightRoles"
315--
316ALTER TABLE dbo.be_RightRoles
317  ADD RightRoleRowId int IDENTITY
318GO
319
320--
321-- Create column "BlogId" on table "dbo.be_RightRoles"
322--
323ALTER TABLE dbo.be_RightRoles
324  ADD BlogId uniqueidentifier NULL
325GO
326
327UPDATE dbo.be_RightRoles SET BlogId = '27604F05-86AD-47EF-9E05-950BB762570C'
328GO
329
330ALTER TABLE dbo.be_RightRoles
331  ALTER
332    COLUMN BlogId uniqueidentifier NOT NULL
333GO
334
335--
336-- Create primary key PK_be_RightRoles on table "be_RightRoles"
337--
338ALTER TABLE dbo.be_RightRoles
339  ADD CONSTRAINT PK_be_RightRoles PRIMARY KEY (RightRoleRowId)
340GO
341
342--
343-- Create index "idx_be_RightRoles_BlogId" on table "be_RightRoles"
344--
345CREATE INDEX idx_be_RightRoles_BlogId
346  ON dbo.be_RightRoles (BlogId)
347GO
348
349--
350-- Drop primary key PK_be_Referrers on table "be_Referrers"
351--
352ALTER TABLE dbo.be_Referrers
353  DROP CONSTRAINT PK_be_Referrers
354GO
355
356--
357-- Create column "ReferrerRowId" on table "dbo.be_Referrers"
358--
359ALTER TABLE dbo.be_Referrers
360  ADD ReferrerRowId int IDENTITY
361GO
362
363--
364-- Create column "BlogId" on table "dbo.be_Referrers"
365--
366ALTER TABLE dbo.be_Referrers
367  ADD BlogId uniqueidentifier NULL
368GO
369
370UPDATE dbo.be_Referrers SET BlogId = '27604F05-86AD-47EF-9E05-950BB762570C'
371GO
372
373ALTER TABLE dbo.be_Referrers
374  ALTER
375    COLUMN BlogId uniqueidentifier NOT NULL
376GO
377
378--
379-- Create primary key PK_be_Referrers on table "be_Referrers"
380--
381ALTER TABLE dbo.be_Referrers
382  ADD CONSTRAINT PK_be_Referrers PRIMARY KEY (ReferrerRowId)
383GO
384
385--
386-- Create index "idx_be_Referrers_BlogId" on table "be_Referrers"
387--
388CREATE INDEX idx_be_Referrers_BlogId
389  ON dbo.be_Referrers (BlogId)
390GO
391
392--
393-- Drop index "I_UserName" from table "be_Profiles"
394--
395DROP INDEX I_UserName ON dbo.be_Profiles
396GO
397
398--
399-- Create column "BlogID" on table "dbo.be_Profiles"
400--
401ALTER TABLE dbo.be_Profiles
402  ADD BlogID uniqueidentifier NULL
403GO
404
405UPDATE dbo.be_Profiles SET BlogID = '27604F05-86AD-47EF-9E05-950BB762570C'
406GO
407
408ALTER TABLE dbo.be_Profiles
409  ALTER
410    COLUMN BlogID uniqueidentifier NOT NULL
411GO
412
413--
414-- Create index "idx_be_Profiles_BlogId_UserName" on table "be_Profiles"
415--
416CREATE INDEX idx_be_Profiles_BlogId_UserName
417  ON dbo.be_Profiles (BlogID, UserName)
418GO
419
420--
421-- Drop primary key PK_be_Posts on table "be_Posts"
422--
423ALTER TABLE dbo.be_Posts
424  DROP CONSTRAINT PK_be_Posts
425GO
426
427--
428-- Create column "PostRowID" on table "dbo.be_Posts"
429--
430ALTER TABLE dbo.be_Posts
431  ADD PostRowID int IDENTITY
432GO
433
434--
435-- Create column "BlogID" on table "dbo.be_Posts"
436--
437ALTER TABLE dbo.be_Posts
438  ADD BlogID uniqueidentifier NULL
439GO
440
441UPDATE dbo.be_Posts SET BlogID = '27604F05-86AD-47EF-9E05-950BB762570C'
442GO
443
444ALTER TABLE dbo.be_Posts
445  ALTER
446    COLUMN BlogID uniqueidentifier NOT NULL
447GO
448
449--
450-- Create primary key PK_be_Posts on table "be_Posts"
451--
452ALTER TABLE dbo.be_Posts
453  ADD CONSTRAINT PK_be_Posts PRIMARY KEY (PostRowID)
454GO
455
456--
457-- Create index "be_Posts_BlogID_PostID" on table "be_Posts"
458--
459CREATE UNIQUE INDEX be_Posts_BlogID_PostID
460  ON dbo.be_Posts (BlogID, PostID)
461GO
462
463--
464-- Drop index "FK_PostID" from table "be_PostTag"
465--
466DROP INDEX FK_PostID ON dbo.be_PostTag
467GO
468
469--
470-- Create column "BlogID" on table "dbo.be_PostTag"
471--
472ALTER TABLE dbo.be_PostTag
473  ADD BlogID uniqueidentifier NULL
474GO
475
476UPDATE dbo.be_PostTag SET BlogID = '27604F05-86AD-47EF-9E05-950BB762570C'
477GO
478
479ALTER TABLE dbo.be_PostTag
480  ALTER
481    COLUMN BlogID uniqueidentifier NOT NULL
482GO
483
484--
485-- Create foreign key  on table "be_PostTag"
486--
487ALTER TABLE dbo.be_PostTag
488  ADD CONSTRAINT FK_be_PostTag_be_Posts FOREIGN KEY (BlogID, PostID) REFERENCES dbo.be_Posts (BlogID, PostID)
489GO
490
491--
492-- Create index "idx_be_PostTag_BlogId_PostId" on table "be_PostTag"
493--
494CREATE INDEX idx_be_PostTag_BlogId_PostId
495  ON dbo.be_PostTag (BlogID, PostID)
496GO
497
498--
499-- Drop index "FK_PostID" from table "be_PostNotify"
500--
501DROP INDEX FK_PostID ON dbo.be_PostNotify
502GO
503
504--
505-- Rename primary key "PK_be_PostNotify" to "idx_be_PostCategory_BlogId_PostId" on Table "be_PostNotify"
506--
507EXEC sp_rename N'dbo.PK_be_PostNotify', N'idx_be_PostCategory_BlogId_PostId', 'OBJECT'
508GO
509
510--
511-- Create column "BlogID" on table "dbo.be_PostNotify"
512--
513ALTER TABLE dbo.be_PostNotify
514  ADD BlogID uniqueidentifier NULL
515GO
516
517UPDATE dbo.be_PostNotify SET BlogID = '27604F05-86AD-47EF-9E05-950BB762570C'
518GO
519
520ALTER TABLE dbo.be_PostNotify
521  ALTER
522    COLUMN BlogID uniqueidentifier NOT NULL
523GO
524
525--
526-- Create foreign key  on table "be_PostNotify"
527--
528ALTER TABLE dbo.be_PostNotify
529  ADD CONSTRAINT FK_be_PostNotify_be_Posts FOREIGN KEY (BlogID, PostID) REFERENCES dbo.be_Posts (BlogID, PostID)
530GO
531
532--
533-- Create index "FK_PostID" on table "be_PostNotify"
534--
535CREATE INDEX FK_PostID
536  ON dbo.be_PostNotify (BlogID, PostID)
537GO
538
539--
540-- Drop index "FK_PostID" from table "be_PostComment"
541--
542DROP INDEX FK_PostID ON dbo.be_PostComment
543GO
544
545--
546-- Drop primary key PK_be_PostComment on table "be_PostComment"
547--
548ALTER TABLE dbo.be_PostComment
549  DROP CONSTRAINT PK_be_PostComment
550GO
551
552--
553-- Create column "PostCommentRowID" on table "dbo.be_PostComment"
554--
555ALTER TABLE dbo.be_PostComment
556  ADD PostCommentRowID int IDENTITY
557GO
558
559--
560-- Create column "BlogID" on table "dbo.be_PostComment"
561--
562ALTER TABLE dbo.be_PostComment
563  ADD BlogID uniqueidentifier NULL
564GO
565
566UPDATE dbo.be_PostComment SET BlogID = '27604F05-86AD-47EF-9E05-950BB762570C'
567GO
568
569ALTER TABLE dbo.be_PostComment
570  ALTER
571    COLUMN BlogID uniqueidentifier NOT NULL
572GO
573
574--
575-- Create primary key PK_be_PostComment on table "be_PostComment"
576--
577ALTER TABLE dbo.be_PostComment
578  ADD CONSTRAINT PK_be_PostComment PRIMARY KEY (PostCommentRowID)
579GO
580
581--
582-- Create index "idx_be_PostComment_BlogId_PostId" on table "be_PostComment"
583--
584CREATE INDEX idx_be_PostComment_BlogId_PostId
585  ON dbo.be_PostComment (BlogID, PostID)
586GO
587
588--
589-- Create foreign key  on table "be_PostComment"
590--
591ALTER TABLE dbo.be_PostComment
592  ADD CONSTRAINT FK_be_PostComment_be_Posts FOREIGN KEY (BlogID, PostID) REFERENCES dbo.be_Posts (BlogID, PostID)
593GO
594
595--
596-- Rename primary key "PK_be_PingService" to "PK_be_PingService_1" on Table "be_PingService"
597--
598EXEC sp_rename N'dbo.PK_be_PingService', N'PK_be_PingService_1', 'OBJECT'
599GO
600
601--
602-- Create column "BlogID" on table "dbo.be_PingService"
603--
604ALTER TABLE dbo.be_PingService
605  ADD BlogID uniqueidentifier NULL
606GO
607
608UPDATE dbo.be_PingService SET BlogID = '27604F05-86AD-47EF-9E05-950BB762570C'
609GO
610
611ALTER TABLE dbo.be_PingService
612  ALTER
613    COLUMN BlogID uniqueidentifier NOT NULL
614GO
615
616--
617-- Create index "idx_be_PingService_BlogId" on table "be_PingService"
618--
619CREATE INDEX idx_be_PingService_BlogId
620  ON dbo.be_PingService (BlogID)
621GO
622
623--
624-- Drop primary key PK_be_Pages on table "be_Pages"
625--
626ALTER TABLE dbo.be_Pages
627  DROP CONSTRAINT PK_be_Pages
628GO
629
630--
631-- Create column "PageRowID" on table "dbo.be_Pages"
632--
633ALTER TABLE dbo.be_Pages
634  ADD PageRowID int IDENTITY
635GO
636
637--
638-- Create column "BlogID" on table "dbo.be_Pages"
639--
640ALTER TABLE dbo.be_Pages
641  ADD BlogID uniqueidentifier NULL
642GO
643
644UPDATE dbo.be_Pages SET BlogID = '27604F05-86AD-47EF-9E05-950BB762570C'
645GO
646
647ALTER TABLE dbo.be_Pages
648  ALTER
649    COLUMN BlogID uniqueidentifier NOT NULL
650GO
651
652--
653-- Create primary key PK_be_Pages on table "be_Pages"
654--
655ALTER TABLE dbo.be_Pages
656  ADD CONSTRAINT PK_be_Pages PRIMARY KEY (PageRowID)
657GO
658
659--
660-- Create index "idx_Pages_BlogId_PageId" on table "be_Pages"
661--
662CREATE INDEX idx_Pages_BlogId_PageId
663  ON dbo.be_Pages (BlogID, PageID)
664GO
665
666--
667-- Drop index "I_TypeID" from table "be_DataStoreSettings"
668--
669DROP INDEX I_TypeID ON dbo.be_DataStoreSettings
670GO
671
672--
673-- Create column "DataStoreSettingRowId" on table "dbo.be_DataStoreSettings"
674--
675ALTER TABLE dbo.be_DataStoreSettings
676  ADD DataStoreSettingRowId int IDENTITY
677GO
678
679--
680-- Create column "BlogId" on table "dbo.be_DataStoreSettings"
681--
682ALTER TABLE dbo.be_DataStoreSettings
683  ADD BlogId uniqueidentifier NULL
684GO
685
686UPDATE dbo.be_DataStoreSettings SET BlogId = '27604F05-86AD-47EF-9E05-950BB762570C'
687GO
688
689ALTER TABLE dbo.be_DataStoreSettings
690  ALTER
691    COLUMN BlogId uniqueidentifier NOT NULL
692GO
693
694--
695-- Create primary key PK_be_DataStoreSettings on table "be_DataStoreSettings"
696--
697ALTER TABLE dbo.be_DataStoreSettings
698  ADD CONSTRAINT PK_be_DataStoreSettings PRIMARY KEY (DataStoreSettingRowId)
699GO
700
701--
702-- Create index "idx_be_DataStoreSettings_BlogId_ExtensionType_TypeID" on table "be_DataStoreSettings"
703--
704CREATE INDEX idx_be_DataStoreSettings_BlogId_ExtensionType_TypeID
705  ON dbo.be_DataStoreSettings (BlogId, ExtensionType, ExtensionId)
706GO
707
708--
709-- Drop primary key PK_be_Categories on table "be_Categories"
710--
711ALTER TABLE dbo.be_Categories
712  DROP CONSTRAINT PK_be_Categories
713GO
714
715--
716-- Create column "CategoryRowID" on table "dbo.be_Categories"
717--
718ALTER TABLE dbo.be_Categories
719  ADD CategoryRowID int IDENTITY
720GO
721
722--
723-- Create column "BlogID" on table "dbo.be_Categories"
724--
725ALTER TABLE dbo.be_Categories
726  ADD BlogID uniqueidentifier NULL
727GO
728
729UPDATE dbo.be_Categories SET BlogID = '27604F05-86AD-47EF-9E05-950BB762570C'
730GO
731
732ALTER TABLE dbo.be_Categories
733  ALTER
734    COLUMN BlogID uniqueidentifier NOT NULL
735GO
736
737--
738-- Create primary key PK_be_Categories on table "be_Categories"
739--
740ALTER TABLE dbo.be_Categories
741  ADD CONSTRAINT PK_be_Categories PRIMARY KEY (CategoryRowID)
742GO
743
744--
745-- Create index "idx_be_Categories_BlogID_CategoryID" on table "be_Categories"
746--
747CREATE UNIQUE INDEX idx_be_Categories_BlogID_CategoryID
748  ON dbo.be_Categories (BlogID, CategoryID)
749GO
750
751--
752-- Drop index "FK_CategoryID" from table "be_PostCategory"
753--
754DROP INDEX FK_CategoryID ON dbo.be_PostCategory
755GO
756
757--
758-- Drop index "FK_PostID" from table "be_PostCategory"
759--
760DROP INDEX FK_PostID ON dbo.be_PostCategory
761GO
762
763--
764-- Rename primary key "PK_be_PostCategory" to "PK_be_PostCategory_1" on Table "be_PostCategory"
765--
766EXEC sp_rename N'dbo.PK_be_PostCategory', N'PK_be_PostCategory_1', 'OBJECT'
767GO
768
769--
770-- Create column "BlogID" on table "dbo.be_PostCategory"
771--
772ALTER TABLE dbo.be_PostCategory
773  ADD BlogID uniqueidentifier NULL
774GO
775
776UPDATE dbo.be_PostCategory SET BlogID = '27604F05-86AD-47EF-9E05-950BB762570C'
777GO
778
779ALTER TABLE dbo.be_PostCategory
780  ALTER
781    COLUMN BlogID uniqueidentifier NOT NULL
782GO
783
784--
785-- Create foreign key  on table "be_PostCategory"
786--
787ALTER TABLE dbo.be_PostCategory
788  ADD CONSTRAINT FK_be_PostCategory_be_Categories FOREIGN KEY (BlogID, CategoryID) REFERENCES dbo.be_Categories (BlogID, CategoryID)
789GO
790
791--
792-- Create foreign key  on table "be_PostCategory"
793--
794ALTER TABLE dbo.be_PostCategory
795  ADD CONSTRAINT FK_be_PostCategory_be_Posts FOREIGN KEY (BlogID, PostID) REFERENCES dbo.be_Posts (BlogID, PostID)
796GO
797
798--
799-- Create index "idx_be_PostCategory_BlogId_CategoryId" on table "be_PostCategory"
800--
801CREATE INDEX idx_be_PostCategory_BlogId_CategoryId
802  ON dbo.be_PostCategory (BlogID, CategoryID)
803GO
804
805--
806-- Create index "idx_be_PostCategory_BlogId_PostId" on table "be_PostCategory"
807--
808CREATE INDEX idx_be_PostCategory_BlogId_PostId
809  ON dbo.be_PostCategory (BlogID, PostID)
810GO
811
812--
813-- Create table "dbo.be_Blogs"
814--
815CREATE TABLE dbo.be_Blogs (
816  BlogRowId int IDENTITY,
817  BlogId uniqueidentifier NOT NULL,
818  BlogName nvarchar(255) NOT NULL,
819  Hostname nvarchar(255) NOT NULL,
820  IsAnyTextBeforeHostnameAccepted bit NOT NULL,
821  StorageContainerName nvarchar(255) NOT NULL,
822  VirtualPath nvarchar(255) NOT NULL,
823  IsPrimary bit NOT NULL,
824  IsActive bit NOT NULL,
825  CONSTRAINT PK_be_Blogs PRIMARY KEY (BlogRowId)
826)
827GO
828
829INSERT [dbo].[be_Blogs] ([BlogId], [BlogName], [Hostname], [IsAnyTextBeforeHostnameAccepted], [StorageContainerName], [VirtualPath], [IsPrimary], [IsActive]) VALUES (N'27604f05-86ad-47ef-9e05-950bb762570c', N'Primary', N'', 0, N'', N'~/', 1, 1)
830GO
831
832--
833-- Drop primary key PK_be_BlogRollItems on table "be_BlogRollItems"
834--
835ALTER TABLE dbo.be_BlogRollItems
836  DROP CONSTRAINT PK_be_BlogRollItems
837GO
838
839--
840-- Create column "BlogRollRowId" on table "dbo.be_BlogRollItems"
841--
842ALTER TABLE dbo.be_BlogRollItems
843  ADD BlogRollRowId int IDENTITY
844GO
845
846--
847-- Create column "BlogId" on table "dbo.be_BlogRollItems"
848--
849ALTER TABLE dbo.be_BlogRollItems
850  ADD BlogId uniqueidentifier NULL
851GO
852
853UPDATE dbo.be_BlogRollItems SET BlogId = '27604F05-86AD-47EF-9E05-950BB762570C'
854GO
855
856ALTER TABLE dbo.be_BlogRollItems
857  ALTER
858    COLUMN BlogId uniqueidentifier NOT NULL
859GO
860
861--
862-- Create primary key PK_be_BlogRollItems on table "be_BlogRollItems"
863--
864ALTER TABLE dbo.be_BlogRollItems
865  ADD CONSTRAINT PK_be_BlogRollItems PRIMARY KEY (BlogRollRowId)
866GO
867
868--
869-- Create index "idx_be_BlogRollItems_BlogId" on table "be_BlogRollItems"
870--
871CREATE INDEX idx_be_BlogRollItems_BlogId
872  ON dbo.be_BlogRollItems (BlogId)
873GO
874