You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. -- Updates from version 0.3.1
  2. ALTER TABLE [dbo].[messages] ADD CONSTRAINT [FK_messages_user_id]
  3. FOREIGN KEY ([user_id]) REFERENCES [dbo].[users] ([user_id])
  4. ON DELETE CASCADE ON UPDATE CASCADE
  5. GO
  6. ALTER TABLE [dbo].[cache] ADD CONSTRAINT [FK_cache_user_id]
  7. FOREIGN KEY ([user_id]) REFERENCES [dbo].[users] ([user_id])
  8. ON DELETE CASCADE ON UPDATE CASCADE
  9. GO
  10. ALTER TABLE [dbo].[contacts] ADD CONSTRAINT [FK_contacts_user_id]
  11. FOREIGN KEY ([user_id]) REFERENCES [dbo].[users] ([user_id])
  12. ON DELETE CASCADE ON UPDATE CASCADE
  13. GO
  14. ALTER TABLE [dbo].[identities] ADD CONSTRAINT [FK_identities_user_id]
  15. FOREIGN KEY ([user_id]) REFERENCES [dbo].[users] ([user_id])
  16. ON DELETE CASCADE ON UPDATE CASCADE
  17. GO
  18. ALTER TABLE [dbo].[identities] ADD [changed] [datetime] NULL
  19. GO
  20. CREATE TABLE [dbo].[contactgroups] (
  21. [contactgroup_id] [int] IDENTITY (1, 1) NOT NULL ,
  22. [user_id] [int] NOT NULL ,
  23. [changed] [datetime] NOT NULL ,
  24. [del] [char] (1) COLLATE Latin1_General_CI_AI NOT NULL ,
  25. [name] [varchar] (128) COLLATE Latin1_General_CI_AI NOT NULL
  26. ) ON [PRIMARY]
  27. GO
  28. CREATE TABLE [dbo].[contactgroupmembers] (
  29. [contactgroup_id] [int] NOT NULL ,
  30. [contact_id] [int] NOT NULL ,
  31. [created] [datetime] NOT NULL
  32. ) ON [PRIMARY]
  33. GO
  34. ALTER TABLE [dbo].[contactgroups] WITH NOCHECK ADD
  35. CONSTRAINT [PK_contactgroups_contactgroup_id] PRIMARY KEY CLUSTERED
  36. (
  37. [contactgroup_id]
  38. ) ON [PRIMARY]
  39. GO
  40. ALTER TABLE [dbo].[contactgroupmembers] WITH NOCHECK ADD
  41. CONSTRAINT [PK_contactgroupmembers_id] PRIMARY KEY CLUSTERED
  42. (
  43. [contactgroup_id], [contact_id]
  44. ) ON [PRIMARY]
  45. GO
  46. ALTER TABLE [dbo].[contactgroups] ADD
  47. CONSTRAINT [DF_contactgroups_user_id] DEFAULT (0) FOR [user_id],
  48. CONSTRAINT [DF_contactgroups_changed] DEFAULT (getdate()) FOR [changed],
  49. CONSTRAINT [DF_contactgroups_del] DEFAULT ('0') FOR [del],
  50. CONSTRAINT [DF_contactgroups_name] DEFAULT ('') FOR [name],
  51. CONSTRAINT [CK_contactgroups_del] CHECK ([del] = '1' or [del] = '0')
  52. GO
  53. CREATE INDEX [IX_contactgroups_user_id] ON [dbo].[contacts]([user_id]) ON [PRIMARY]
  54. GO
  55. ALTER TABLE [dbo].[contactgroupmembers] ADD
  56. CONSTRAINT [DF_contactgroupmembers_contactgroup_id] DEFAULT (0) FOR [contactgroup_id],
  57. CONSTRAINT [DF_contactgroupmembers_contact_id] DEFAULT (0) FOR [contact_id],
  58. CONSTRAINT [DF_contactgroupmembers_created] DEFAULT (getdate()) FOR [created]
  59. GO
  60. ALTER TABLE [dbo].[contactgroupmembers] ADD CONSTRAINT [FK_contactgroupmembers_contactgroup_id]
  61. FOREIGN KEY ([contactgroup_id]) REFERENCES [dbo].[contactgroups] ([contactgroup_id])
  62. ON DELETE CASCADE ON UPDATE CASCADE
  63. GO
  64. CREATE TRIGGER [contact_delete_member] ON [dbo].[contacts]
  65. AFTER DELETE AS
  66. DELETE FROM [dbo].[contactgroupmembers]
  67. WHERE [contact_id] IN (SELECT [contact_id] FROM deleted)
  68. GO
  69. ALTER TABLE [dbo].[contactgroups] ADD CONSTRAINT [FK_contactgroups_user_id]
  70. FOREIGN KEY ([user_id]) REFERENCES [dbo].[users] ([user_id])
  71. ON DELETE CASCADE ON UPDATE CASCADE
  72. GO