UserAccount.migrations 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. :VERSION 1
  2. CREATE TABLE [UserAccounts] (
  3. [PrincipalID] uniqueidentifier NOT NULL,
  4. [ScopeID] uniqueidentifier NOT NULL,
  5. [FirstName] [varchar](64) NOT NULL,
  6. [LastName] [varchar](64) NOT NULL,
  7. [Email] [varchar](64) NULL,
  8. [ServiceURLs] [text] NULL,
  9. [Created] [int] default NULL,
  10. PRIMARY KEY CLUSTERED
  11. (
  12. [PrincipalID] ASC
  13. )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  14. ) ON [PRIMARY]
  15. :VERSION 2
  16. BEGIN TRANSACTION
  17. IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[users]') AND type in (N'U'))
  18. INSERT INTO UserAccounts (PrincipalID, ScopeID, FirstName, LastName, Email, ServiceURLs, Created) SELECT [UUID] AS PrincipalID, '00000000-0000-0000-0000-000000000000' AS ScopeID,
  19. username AS FirstName,
  20. lastname AS LastName,
  21. email as Email, (
  22. 'AssetServerURI=' +
  23. userAssetURI + ' InventoryServerURI=' + userInventoryURI + ' GatewayURI= HomeURI=') AS ServiceURLs,
  24. created as Created FROM users;
  25. COMMIT
  26. :VERSION 3
  27. BEGIN TRANSACTION
  28. CREATE UNIQUE INDEX PrincipalID ON UserAccounts(PrincipalID);
  29. CREATE INDEX Email ON UserAccounts(Email);
  30. CREATE INDEX FirstName ON UserAccounts(FirstName);
  31. CREATE INDEX LastName ON UserAccounts(LastName);
  32. CREATE INDEX Name ON UserAccounts(FirstName,LastName);
  33. COMMIT
  34. :VERSION 4
  35. BEGIN TRANSACTION
  36. ALTER TABLE UserAccounts ADD UserLevel integer NOT NULL DEFAULT 0;
  37. ALTER TABLE UserAccounts ADD UserFlags integer NOT NULL DEFAULT 0;
  38. ALTER TABLE UserAccounts ADD UserTitle varchar(64) NOT NULL DEFAULT '';
  39. COMMIT