From 9b2c4adb548cf76c9814dc799c0bb3fff5925309 Mon Sep 17 00:00:00 2001
From: alec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c>
Date: Mon, 15 Nov 2010 14:03:22 +0000
Subject: - Fix error in MSSQL DDL scripts (#1487112): use trigger instead of
 foreign key constraint

git-svn-id: https://svn.roundcube.net/trunk@4226 208e9e7b-5314-0410-a742-e7e81cd9613c
---
 roundcubemail/SQL/mssql.upgrade.sql | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

(limited to 'roundcubemail/SQL/mssql.upgrade.sql')

diff --git a/roundcubemail/SQL/mssql.upgrade.sql b/roundcubemail/SQL/mssql.upgrade.sql
index cf0c17157..4072c25ff 100644
--- a/roundcubemail/SQL/mssql.upgrade.sql
+++ b/roundcubemail/SQL/mssql.upgrade.sql
@@ -77,9 +77,10 @@ ALTER TABLE [dbo].[contactgroupmembers] ADD CONSTRAINT [FK_contactgroupmembers_c
     ON DELETE CASCADE ON UPDATE CASCADE
 GO
 
-ALTER TABLE [dbo].[contactgroupmembers] ADD CONSTRAINT [FK_contactgroupmembers_contact_id] 
-    FOREIGN KEY ([contact_id]) REFERENCES [dbo].[contacts] ([contact_id])
-    ON DELETE CASCADE ON UPDATE CASCADE
+CREATE TRIGGER [contact_delete_member] ON [dbo].[contacts]
+    AFTER DELETE AS
+    DELETE FROM [dbo].[contactgroupmembers]
+    WHERE [contact_id] IN (SELECT [contact_id] FROM deleted)
 GO
 
 ALTER TABLE [dbo].[contactgroups] ADD CONSTRAINT [FK_contactgroups_user_id]
-- 
cgit v1.2.3

