summaryrefslogtreecommitdiff
path: root/SQL/mssql.initial.sql
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2011-09-06 16:35:14 +0000
committeralecpl <alec@alec.pl>2011-09-06 16:35:14 +0000
commitf8e48df71540b268ceac058d32b8ee848fc2ab6b (patch)
treed2e8ea19086014e8a89f761a9444e72d84145164 /SQL/mssql.initial.sql
parent66df084203a217ab74a416064c459cc3420a648c (diff)
- Merge devel-saved_search branch (Addressbook Saved Searches)
Diffstat (limited to 'SQL/mssql.initial.sql')
-rw-r--r--SQL/mssql.initial.sql29
1 files changed, 29 insertions, 0 deletions
diff --git a/SQL/mssql.initial.sql b/SQL/mssql.initial.sql
index 321da7cbb..8e103eb55 100644
--- a/SQL/mssql.initial.sql
+++ b/SQL/mssql.initial.sql
@@ -100,6 +100,15 @@ CREATE TABLE [dbo].[dictionary] (
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
+CREATE TABLE [dbo].[searches] (
+ [search_id] [int] IDENTITY (1, 1) NOT NULL ,
+ [user_id] [int] NOT NULL ,
+ [type] [tinyint] NOT NULL ,
+ [name] [varchar] (128) COLLATE Latin1_General_CI_AI NOT NULL ,
+ [data] [text] COLLATE Latin1_General_CI_AI NOT NULL
+) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
+GO
+
ALTER TABLE [dbo].[cache] WITH NOCHECK ADD
PRIMARY KEY CLUSTERED
(
@@ -156,6 +165,13 @@ ALTER TABLE [dbo].[users] WITH NOCHECK ADD
) ON [PRIMARY]
GO
+ALTER TABLE [dbo].[searches] WITH NOCHECK ADD
+ CONSTRAINT [PK_searches_search_id] PRIMARY KEY CLUSTERED
+ (
+ [search_id]
+ ) ON [PRIMARY]
+GO
+
ALTER TABLE [dbo].[cache] ADD
CONSTRAINT [DF_cache_user_id] DEFAULT ('0') FOR [user_id],
CONSTRAINT [DF_cache_cache_key] DEFAULT ('') FOR [cache_key],
@@ -274,6 +290,14 @@ GO
CREATE UNIQUE INDEX [IX_dictionary_user_language] ON [dbo].[dictionary]([user_id],[language]) ON [PRIMARY]
GO
+ALTER TABLE [dbo].[searches] ADD
+ CONSTRAINT [DF_searches_user] DEFAULT (0) FOR [user_id],
+ CONSTRAINT [DF_searches_type] DEFAULT (0) FOR [type],
+GO
+
+CREATE UNIQUE INDEX [IX_searches_user_type_name] ON [dbo].[searches]([user_id],[type],[name]) ON [PRIMARY]
+GO
+
ALTER TABLE [dbo].[identities] ADD CONSTRAINT [FK_identities_user_id]
FOREIGN KEY ([user_id]) REFERENCES [dbo].[users] ([user_id])
ON DELETE CASCADE ON UPDATE CASCADE
@@ -304,6 +328,11 @@ ALTER TABLE [dbo].[contactgroupmembers] ADD CONSTRAINT [FK_contactgroupmembers_c
ON DELETE CASCADE ON UPDATE CASCADE
GO
+ALTER TABLE [dbo].[searches] ADD CONSTRAINT [FK_searches_user_id]
+ FOREIGN KEY ([user_id]) REFERENCES [dbo].[users] ([user_id])
+ ON DELETE CASCADE ON UPDATE CASCADE
+GO
+
-- Use trigger instead of foreign key (#1487112)
-- "Introducing FOREIGN KEY constraint ... may cause cycles or multiple cascade paths."
CREATE TRIGGER [contact_delete_member] ON [dbo].[contacts]