Mercurial > hg > rc2
comparison SQL/mssql/2009103100.sql @ 0:4681f974d28b
vanilla 1.3.3 distro, I hope
author | Charlie Root |
---|---|
date | Thu, 04 Jan 2018 15:52:31 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4681f974d28b |
---|---|
1 -- Updates from version 0.3.1 | |
2 | |
3 ALTER TABLE [dbo].[messages] ADD CONSTRAINT [FK_messages_user_id] | |
4 FOREIGN KEY ([user_id]) REFERENCES [dbo].[users] ([user_id]) | |
5 ON DELETE CASCADE ON UPDATE CASCADE | |
6 GO | |
7 | |
8 ALTER TABLE [dbo].[cache] ADD CONSTRAINT [FK_cache_user_id] | |
9 FOREIGN KEY ([user_id]) REFERENCES [dbo].[users] ([user_id]) | |
10 ON DELETE CASCADE ON UPDATE CASCADE | |
11 GO | |
12 | |
13 ALTER TABLE [dbo].[contacts] ADD CONSTRAINT [FK_contacts_user_id] | |
14 FOREIGN KEY ([user_id]) REFERENCES [dbo].[users] ([user_id]) | |
15 ON DELETE CASCADE ON UPDATE CASCADE | |
16 GO | |
17 | |
18 ALTER TABLE [dbo].[identities] ADD CONSTRAINT [FK_identities_user_id] | |
19 FOREIGN KEY ([user_id]) REFERENCES [dbo].[users] ([user_id]) | |
20 ON DELETE CASCADE ON UPDATE CASCADE | |
21 GO | |
22 | |
23 ALTER TABLE [dbo].[identities] ADD [changed] [datetime] NULL | |
24 GO | |
25 | |
26 CREATE TABLE [dbo].[contactgroups] ( | |
27 [contactgroup_id] [int] IDENTITY (1, 1) NOT NULL , | |
28 [user_id] [int] NOT NULL , | |
29 [changed] [datetime] NOT NULL , | |
30 [del] [char] (1) COLLATE Latin1_General_CI_AI NOT NULL , | |
31 [name] [varchar] (128) COLLATE Latin1_General_CI_AI NOT NULL | |
32 ) ON [PRIMARY] | |
33 GO | |
34 | |
35 CREATE TABLE [dbo].[contactgroupmembers] ( | |
36 [contactgroup_id] [int] NOT NULL , | |
37 [contact_id] [int] NOT NULL , | |
38 [created] [datetime] NOT NULL | |
39 ) ON [PRIMARY] | |
40 GO | |
41 | |
42 ALTER TABLE [dbo].[contactgroups] WITH NOCHECK ADD | |
43 CONSTRAINT [PK_contactgroups_contactgroup_id] PRIMARY KEY CLUSTERED | |
44 ( | |
45 [contactgroup_id] | |
46 ) ON [PRIMARY] | |
47 GO | |
48 | |
49 ALTER TABLE [dbo].[contactgroupmembers] WITH NOCHECK ADD | |
50 CONSTRAINT [PK_contactgroupmembers_id] PRIMARY KEY CLUSTERED | |
51 ( | |
52 [contactgroup_id], [contact_id] | |
53 ) ON [PRIMARY] | |
54 GO | |
55 | |
56 ALTER TABLE [dbo].[contactgroups] ADD | |
57 CONSTRAINT [DF_contactgroups_user_id] DEFAULT (0) FOR [user_id], | |
58 CONSTRAINT [DF_contactgroups_changed] DEFAULT (getdate()) FOR [changed], | |
59 CONSTRAINT [DF_contactgroups_del] DEFAULT ('0') FOR [del], | |
60 CONSTRAINT [DF_contactgroups_name] DEFAULT ('') FOR [name], | |
61 CONSTRAINT [CK_contactgroups_del] CHECK ([del] = '1' or [del] = '0') | |
62 GO | |
63 | |
64 CREATE INDEX [IX_contactgroups_user_id] ON [dbo].[contacts]([user_id]) ON [PRIMARY] | |
65 GO | |
66 | |
67 ALTER TABLE [dbo].[contactgroupmembers] ADD | |
68 CONSTRAINT [DF_contactgroupmembers_contactgroup_id] DEFAULT (0) FOR [contactgroup_id], | |
69 CONSTRAINT [DF_contactgroupmembers_contact_id] DEFAULT (0) FOR [contact_id], | |
70 CONSTRAINT [DF_contactgroupmembers_created] DEFAULT (getdate()) FOR [created] | |
71 GO | |
72 | |
73 ALTER TABLE [dbo].[contactgroupmembers] ADD CONSTRAINT [FK_contactgroupmembers_contactgroup_id] | |
74 FOREIGN KEY ([contactgroup_id]) REFERENCES [dbo].[contactgroups] ([contactgroup_id]) | |
75 ON DELETE CASCADE ON UPDATE CASCADE | |
76 GO | |
77 | |
78 CREATE TRIGGER [contact_delete_member] ON [dbo].[contacts] | |
79 AFTER DELETE AS | |
80 DELETE FROM [dbo].[contactgroupmembers] | |
81 WHERE [contact_id] IN (SELECT [contact_id] FROM deleted) | |
82 GO | |
83 | |
84 ALTER TABLE [dbo].[contactgroups] ADD CONSTRAINT [FK_contactgroups_user_id] | |
85 FOREIGN KEY ([user_id]) REFERENCES [dbo].[users] ([user_id]) | |
86 ON DELETE CASCADE ON UPDATE CASCADE | |
87 GO |