[Svn] r3891 - in trunk/roundcubemail: . SQL

trac at roundcube.net trac at roundcube.net
Wed Aug 11 11:22:14 CEST 2010


Author: alec
Date: 2010-08-11 04:22:14 -0500 (Wed, 11 Aug 2010)
New Revision: 3891

Added:
   trunk/roundcubemail/SQL/mssql.upgrade.sql
Modified:
   trunk/roundcubemail/CHANGELOG
   trunk/roundcubemail/SQL/mssql.initial.sql
Log:
- Fixes in SQL init script + added update script for MSSQL database


Modified: trunk/roundcubemail/CHANGELOG
===================================================================
--- trunk/roundcubemail/CHANGELOG	2010-08-11 09:10:34 UTC (rev 3890)
+++ trunk/roundcubemail/CHANGELOG	2010-08-11 09:22:14 UTC (rev 3891)
@@ -4,6 +4,7 @@
 - Improve handling of single-part messages with bogus BODYSTRUCTURE (#1486898)
 - Fix path to SQL files when using pgsql/mysqli/sqlsrv drivers (#1486902)
 - Fix upgrade script for SQLite (#1486903)
+- Fixes in SQL init script + added update script for MSSQL database
 
 RELEASE 0.4
 -----------

Modified: trunk/roundcubemail/SQL/mssql.initial.sql
===================================================================
--- trunk/roundcubemail/SQL/mssql.initial.sql	2010-08-11 09:10:34 UTC (rev 3890)
+++ trunk/roundcubemail/SQL/mssql.initial.sql	2010-08-11 09:22:14 UTC (rev 3891)
@@ -26,14 +26,14 @@
 	[changed] [datetime] NOT NULL ,
 	[del] [char] (1) COLLATE Latin1_General_CI_AI NOT NULL ,
 	[name] [varchar] (128) COLLATE Latin1_General_CI_AI NOT NULL
-) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
+) ON [PRIMARY] 
 GO
 
 CREATE TABLE [dbo].[contactgroupmembers] (
 	[contactgroup_id] [int] NOT NULL ,
 	[contact_id] [int] NOT NULL ,
 	[created] [datetime] NOT NULL
-) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
+) ON [PRIMARY] 
 GO
 
 CREATE TABLE [dbo].[identities] (
@@ -261,38 +261,38 @@
 CREATE  INDEX [IX_users_alias] ON [dbo].[users]([alias]) ON [PRIMARY]
 GO
 
-ALTER TABLE [dbo].[identities] ADD
-    FOREIGN KEY ([FK_identities_user_id]) REFERENCES [dbo].[users] ([user_id])
+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
 GO
 
-ALTER TABLE [dbo].[contacts] ADD
-    FOREIGN KEY ([FK_contacts_user_id]) REFERENCES [dbo].[users] ([user_id])
+ALTER TABLE [dbo].[contacts] ADD CONSTRAINT [FK_contacts_user_id]
+    FOREIGN KEY ([user_id]) REFERENCES [dbo].[users] ([user_id])
     ON DELETE CASCADE ON UPDATE CASCADE
 GO
 
-ALTER TABLE [dbo].[contactgroups] ADD
-    FOREIGN KEY ([FK_contactgroups_user_id]) REFERENCES [dbo].[users] ([user_id])
+ALTER TABLE [dbo].[contactgroups] ADD CONSTRAINT [FK_contactgroups_user_id]
+    FOREIGN KEY ([user_id]) REFERENCES [dbo].[users] ([user_id])
     ON DELETE CASCADE ON UPDATE CASCADE
 GO
 
-ALTER TABLE [dbo].[cache] ADD
-    FOREIGN KEY ([FK_cache_user_id]) REFERENCES [dbo].[users] ([user_id])
+ALTER TABLE [dbo].[cache] ADD CONSTRAINT [FK_cache_user_id]
+    FOREIGN KEY ([user_id]) REFERENCES [dbo].[users] ([user_id])
     ON DELETE CASCADE ON UPDATE CASCADE
 GO
 
-ALTER TABLE [dbo].[messages] ADD
-    FOREIGN KEY ([FK_messages_user_id]) REFERENCES [dbo].[users] ([user_id])
+ALTER TABLE [dbo].[messages] ADD CONSTRAINT [FK_messages_user_id]
+    FOREIGN KEY ([user_id]) REFERENCES [dbo].[users] ([user_id])
     ON DELETE CASCADE ON UPDATE CASCADE
 GO
 
-ALTER TABLE [dbo].[contactgroupmembers] ADD
-    FOREIGN KEY ([FK_contactgroupmembers_contactgroup_id]) REFERENCES [dbo].[contactgroups] ([contactgroup_id])
+ALTER TABLE [dbo].[contactgroupmembers] ADD CONSTRAINT [FK_contactgroupmembers_contactgroup_id]
+    FOREIGN KEY ([contactgroup_id]) REFERENCES [dbo].[contactgroups] ([contactgroup_id])
     ON DELETE CASCADE ON UPDATE CASCADE
 GO
 
-ALTER TABLE [dbo].[contactgroupmembers] ADD
-    FOREIGN KEY ([FK_contactgroupmembers_contact_id]) REFERENCES [dbo].[contacts] ([contact_id])
+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
 GO
 

Added: trunk/roundcubemail/SQL/mssql.upgrade.sql
===================================================================
--- trunk/roundcubemail/SQL/mssql.upgrade.sql	                        (rev 0)
+++ trunk/roundcubemail/SQL/mssql.upgrade.sql	2010-08-11 09:22:14 UTC (rev 3891)
@@ -0,0 +1,89 @@
+-- RoundCube Webmail update script for MSSQL databases
+
+-- Updates from version 0.3.1
+
+ALTER TABLE [dbo].[messages] ADD CONSTRAINT [FK_messages_user_id]
+    FOREIGN KEY ([user_id]) REFERENCES [dbo].[users] ([user_id])
+    ON DELETE CASCADE ON UPDATE CASCADE
+GO
+
+ALTER TABLE [dbo].[cache] ADD CONSTRAINT [FK_cache_user_id]
+    FOREIGN KEY ([user_id]) REFERENCES [dbo].[users] ([user_id])
+    ON DELETE CASCADE ON UPDATE CASCADE
+GO
+
+ALTER TABLE [dbo].[contacts] ADD CONSTRAINT [FK_contacts_user_id]
+    FOREIGN KEY ([user_id]) REFERENCES [dbo].[users] ([user_id])
+    ON DELETE CASCADE ON UPDATE CASCADE
+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
+GO
+
+ALTER TABLE [dbo].[identities] add [changed] [datetime] NULL 
+GO
+
+CREATE TABLE [dbo].[contactgroups] (
+	[contactgroup_id] [int] IDENTITY (1, 1) NOT NULL ,
+	[user_id] [int] NOT NULL ,
+	[changed] [datetime] NOT NULL ,
+	[del] [char] (1) COLLATE Latin1_General_CI_AI NOT NULL ,
+	[name] [varchar] (128) COLLATE Latin1_General_CI_AI NOT NULL
+) ON [PRIMARY] 
+GO
+
+CREATE TABLE [dbo].[contactgroupmembers] (
+	[contactgroup_id] [int] NOT NULL ,
+	[contact_id] [int] NOT NULL ,
+	[created] [datetime] NOT NULL
+) ON [PRIMARY] 
+GO
+
+ALTER TABLE [dbo].[contactgroups] WITH NOCHECK ADD 
+	CONSTRAINT [PK_contactgroups_contactgroup_id] PRIMARY KEY CLUSTERED 
+	(
+		[contactgroup_id]
+	)  ON [PRIMARY] 
+GO
+
+ALTER TABLE [dbo].[contactgroupmembers] WITH NOCHECK ADD 
+	CONSTRAINT [PK_contactgroupmembers_id] PRIMARY KEY CLUSTERED 
+	(
+		[contactgroup_id], [contact_id]
+	)  ON [PRIMARY] 
+GO
+
+ALTER TABLE [dbo].[contactgroups] ADD 
+	CONSTRAINT [DF_contactgroups_user_id] DEFAULT (0) FOR [user_id],
+	CONSTRAINT [DF_contactgroups_changed] DEFAULT (getdate()) FOR [changed],
+	CONSTRAINT [DF_contactgroups_del] DEFAULT ('0') FOR [del],
+	CONSTRAINT [DF_contactgroups_name] DEFAULT ('') FOR [name],
+	CONSTRAINT [CK_contactgroups_del] CHECK ([del] = '1' or [del] = '0')
+GO
+
+CREATE  INDEX [IX_contactgroups_user_id] ON [dbo].[contacts]([user_id]) ON [PRIMARY]
+GO
+
+ALTER TABLE [dbo].[contactgroupmembers] ADD 
+	CONSTRAINT [DF_contactgroupmembers_contactgroup_id] DEFAULT (0) FOR [contactgroup_id],
+	CONSTRAINT [DF_contactgroupmembers_contact_id] DEFAULT (0) FOR [contact_id],
+	CONSTRAINT [DF_contactgroupmembers_created] DEFAULT (getdate()) FOR [created]
+GO
+
+ALTER TABLE [dbo].[contactgroupmembers] ADD CONSTRAINT [FK_contactgroupmembers_contactgroup_id]
+    FOREIGN KEY ([contactgroup_id]) REFERENCES [dbo].[contactgroups] ([contactgroup_id])
+    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
+GO
+
+ALTER TABLE [dbo].[contactgroups] ADD CONSTRAINT [FK_contactgroups_user_id]
+    FOREIGN KEY ([user_id]) REFERENCES [dbo].[users] ([user_id])
+    ON DELETE CASCADE ON UPDATE CASCADE
+GO
+

_______________________________________________
http://lists.roundcube.net/mailman/listinfo/svn



More information about the Svn mailing list