003_InventoryStore.sql 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /* To prevent any potential data loss issues, you should review this script in detail before running it outside the context of the database designer.*/
  2. BEGIN TRANSACTION
  3. CREATE TABLE dbo.Tmp_inventoryfolders
  4. (
  5. folderID uniqueidentifier NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000'),
  6. agentID uniqueidentifier NULL DEFAULT (NULL),
  7. parentFolderID uniqueidentifier NULL DEFAULT (NULL),
  8. folderName varchar(64) NULL DEFAULT (NULL),
  9. type smallint NOT NULL DEFAULT ((0)),
  10. version int NOT NULL DEFAULT ((0))
  11. ) ON [PRIMARY]
  12. IF EXISTS(SELECT * FROM dbo.inventoryfolders)
  13. EXEC('INSERT INTO dbo.Tmp_inventoryfolders (folderID, agentID, parentFolderID, folderName, type, version)
  14. SELECT CONVERT(uniqueidentifier, folderID), CONVERT(uniqueidentifier, agentID), CONVERT(uniqueidentifier, parentFolderID), folderName, type, version FROM dbo.inventoryfolders WITH (HOLDLOCK TABLOCKX)')
  15. DROP TABLE dbo.inventoryfolders
  16. EXECUTE sp_rename N'dbo.Tmp_inventoryfolders', N'inventoryfolders', 'OBJECT'
  17. ALTER TABLE dbo.inventoryfolders ADD CONSTRAINT
  18. PK__inventor__C2FABFB3173876EA PRIMARY KEY CLUSTERED
  19. (
  20. folderID
  21. ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  22. CREATE NONCLUSTERED INDEX owner ON dbo.inventoryfolders
  23. (
  24. agentID
  25. ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  26. CREATE NONCLUSTERED INDEX parent ON dbo.inventoryfolders
  27. (
  28. parentFolderID
  29. ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  30. COMMIT