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