diff options
author | thomascube <thomas@roundcube.net> | 2008-04-05 12:49:21 +0000 |
---|---|---|
committer | thomascube <thomas@roundcube.net> | 2008-04-05 12:49:21 +0000 |
commit | e70d6ea64e711096af36b1234f8545b870ea5f45 (patch) | |
tree | 98e784b95d08418d85a17af767037e8a6e0f3f41 /SQL | |
parent | cb1330b7b10ce46e466850b27300a06ed122501e (diff) |
Apply changes from trunk to 0.1-stable
Diffstat (limited to 'SQL')
-rw-r--r-- | SQL/mysql.initial.sql | 11 | ||||
-rw-r--r-- | SQL/mysql.update-0.1a.sql | 51 | ||||
-rw-r--r-- | SQL/mysql.update.sql | 24 | ||||
-rw-r--r-- | SQL/mysql5.initial.sql | 23 | ||||
-rw-r--r-- | SQL/postgres.initial.sql | 14 | ||||
-rw-r--r-- | SQL/postgres.update.sql | 24 | ||||
-rw-r--r-- | SQL/sqlite.initial.sql | 16 | ||||
-rw-r--r-- | SQL/sqlite.update.sql | 11 |
8 files changed, 54 insertions, 120 deletions
diff --git a/SQL/mysql.initial.sql b/SQL/mysql.initial.sql index 926a83eab..ae195e438 100644 --- a/SQL/mysql.initial.sql +++ b/SQL/mysql.initial.sql @@ -1,5 +1,5 @@ -- RoundCube Webmail initial database structure --- Version 0.1-rc1 +-- Version 0.1 -- -- -------------------------------------------------------- @@ -16,9 +16,7 @@ CREATE TABLE `cache` ( `created` datetime NOT NULL default '0000-00-00 00:00:00', `data` longtext NOT NULL, PRIMARY KEY (`cache_id`), - KEY `user_id` (`user_id`), - KEY `cache_key` (`cache_key`), - KEY `session_id` (`session_id`) + INDEX `user_cache_index` (`user_id`,`cache_key`) ); -- -------------------------------------------------------- @@ -118,10 +116,7 @@ CREATE TABLE `messages` ( `size` int(11) unsigned NOT NULL default '0', `headers` text NOT NULL, `structure` text, - PRIMARY KEY (`message_id`), - KEY `user_id` (`user_id`), - KEY `idx` (`idx`), - KEY `uid` (`uid`), + PRIMARY KEY (`message_id`), UNIQUE `uniqueness` (`user_id`, `cache_key`, `uid`) ); diff --git a/SQL/mysql.update-0.1a.sql b/SQL/mysql.update-0.1a.sql deleted file mode 100644 index 60f22b3d6..000000000 --- a/SQL/mysql.update-0.1a.sql +++ /dev/null @@ -1,51 +0,0 @@ --- RoundCube Webmail update script for MySQL databases --- Updates from version 0.1-20051007 - - -ALTER TABLE `session` ADD `ip` VARCHAR(40) NOT NULL AFTER changed; -ALTER TABLE `users` ADD `alias` VARCHAR(128) NOT NULL AFTER mail_host; - - - --- RoundCube Webmail update script for MySQL databases --- Updates from version 0.1-20051021 - -ALTER TABLE `session` CHANGE `sess_id` `sess_id` VARCHAR(40) NOT NULL; - -ALTER TABLE `contacts` CHANGE `del` `del` TINYINT(1) NOT NULL; -ALTER TABLE `contacts` ADD `changed` DATETIME NOT NULL AFTER `user_id`; - -UPDATE `contacts` SET `del`=0 WHERE `del`=1; -UPDATE `contacts` SET `del`=1 WHERE `del`=2; - -ALTER TABLE `identities` CHANGE `default` `standard` TINYINT(1) NOT NULL; -ALTER TABLE `identities` CHANGE `del` `del` TINYINT(1) NOT NULL; - -UPDATE `identities` SET `del`=0 WHERE `del`=1; -UPDATE `identities` SET `del`=1 WHERE `del`=2; -UPDATE `identities` SET `standard`=0 WHERE `standard`=1; -UPDATE `identities` SET `standard`=1 WHERE `standard`=2; - -CREATE TABLE `messages` ( - `message_id` int(11) unsigned NOT NULL auto_increment, - `user_id` int(11) unsigned NOT NULL default '0', - `del` tinyint(1) NOT NULL default '0', - `cache_key` varchar(128) NOT NULL default '', - `created` datetime NOT NULL default '0000-00-00 00:00:00', - `idx` int(11) unsigned NOT NULL default '0', - `uid` int(11) unsigned NOT NULL default '0', - `subject` varchar(255) NOT NULL default '', - `from` varchar(255) NOT NULL default '', - `to` varchar(255) NOT NULL default '', - `cc` varchar(255) NOT NULL default '', - `date` datetime NOT NULL default '0000-00-00 00:00:00', - `size` int(11) unsigned NOT NULL default '0', - `headers` text NOT NULL, - `structure` text, - PRIMARY KEY (`message_id`), - KEY `user_id` (`user_id`), - KEY `idx` (`idx`), - KEY `uid` (`uid`), - UNIQUE `uniqueness` (`cache_key`, `uid`) -) TYPE=MyISAM; - diff --git a/SQL/mysql.update.sql b/SQL/mysql.update.sql index e904be278..11e744cfa 100644 --- a/SQL/mysql.update.sql +++ b/SQL/mysql.update.sql @@ -1,21 +1,17 @@ -- RoundCube Webmail update script for MySQL databases --- Updates from version 0.1-beta and 0.1-beta2 +-- Updates from version 0.1-stable to 0.1.1 TRUNCATE TABLE `messages`; ALTER TABLE `messages` - DROP `body`, - DROP INDEX `cache_key`, - ADD `structure` TEXT, - ADD UNIQUE `uniqueness` (`user_id`, `cache_key`, `uid`); + DROP INDEX `idx`, + DROP INDEX `uid` -ALTER TABLE `identities` - ADD `html_signature` tinyint(1) default 0 NOT NULL; +ALTER TABLE `cache` + DROP INDEX `cache_key`, + DROP INDEX `session_id`, + ADD INDEX `user_cache_index` (`user_id`,`cache_key`); -ALTER TABLE `session` CHANGE `ip` `ip` VARCHAR(40) - --- Uncomment these lines if you're using MySQL 4.1 or higher --- ALTER TABLE `users` --- DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci, --- CHANGE `username` `username` VARCHAR( 128 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, --- CHANGE `alias` `alias` VARCHAR( 128 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL; +ALTER TABLE `users` + ADD INDEX `username_index` (`username`), + ADD INDEX `alias_index` (`alias`); diff --git a/SQL/mysql5.initial.sql b/SQL/mysql5.initial.sql index 1a6ef1990..881344b98 100644 --- a/SQL/mysql5.initial.sql +++ b/SQL/mysql5.initial.sql @@ -1,5 +1,5 @@ -- RoundCube Webmail initial database structure --- Version 0.1-rc1 +-- Version 0.1 -- -------------------------------------------------------- @@ -15,7 +15,7 @@ CREATE TABLE `session` ( `ip` varchar(40) NOT NULL, `vars` text NOT NULL, PRIMARY KEY(`sess_id`) -) TYPE=MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci; +) TYPE=INNODB CHARACTER SET utf8 COLLATE utf8_general_ci; -- Table structure for table `users` @@ -29,8 +29,10 @@ CREATE TABLE `users` ( `last_login` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `language` varchar(5) NOT NULL DEFAULT 'en', `preferences` text, - PRIMARY KEY(`user_id`) -) TYPE=MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci; + PRIMARY KEY(`user_id`), + INDEX `username_index` (`username`), + INDEX `alias_index` (`alias`) +) TYPE=INNODB CHARACTER SET utf8 COLLATE utf8_general_ci; -- Table structure for table `messages` @@ -52,14 +54,12 @@ CREATE TABLE `messages` ( `headers` text NOT NULL, `structure` text, PRIMARY KEY(`message_id`), - INDEX `idx`(`idx`), - INDEX `uid`(`uid`), UNIQUE `uniqueness` (`user_id`, `cache_key`, `uid`), CONSTRAINT `user_id_fk_messages` FOREIGN KEY (`user_id`) REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE -) TYPE=MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci; +) TYPE=INNODB CHARACTER SET utf8 COLLATE utf8_general_ci; -- Table structure for table `cache` @@ -72,13 +72,12 @@ CREATE TABLE `cache` ( `data` longtext NOT NULL, `user_id` int(10) UNSIGNED NOT NULL DEFAULT '0', PRIMARY KEY(`cache_id`), - INDEX `cache_key`(`cache_key`), - INDEX `session_id`(`session_id`), + INDEX `user_cache_index` (`user_id`,`cache_key`), CONSTRAINT `user_id_fk_cache` FOREIGN KEY (`user_id`) REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE -) TYPE=MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci; +) TYPE=INNODB CHARACTER SET utf8 COLLATE utf8_general_ci; -- Table structure for table `contacts` @@ -98,7 +97,7 @@ CREATE TABLE `contacts` ( REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE -) TYPE=MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci; +) TYPE=INNODB CHARACTER SET utf8 COLLATE utf8_general_ci; -- Table structure for table `identities` @@ -120,7 +119,7 @@ CREATE TABLE `identities` ( REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE -) TYPE=MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci; +) TYPE=INNODB CHARACTER SET utf8 COLLATE utf8_general_ci; SET FOREIGN_KEY_CHECKS=1; diff --git a/SQL/postgres.initial.sql b/SQL/postgres.initial.sql index 356a579fc..ff239cbf8 100644 --- a/SQL/postgres.initial.sql +++ b/SQL/postgres.initial.sql @@ -26,7 +26,6 @@ CREATE TABLE users ( ); - -- -- Table "session" -- Name: session; Type: TABLE; Schema: public; Owner: postgres @@ -61,7 +60,7 @@ CREATE SEQUENCE identity_ids CREATE TABLE identities ( identity_id integer DEFAULT nextval('identity_ids'::text) PRIMARY KEY, - user_id integer NOT NULL REFERENCES users (user_id), + user_id integer NOT NULL REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE, del integer DEFAULT 0 NOT NULL, standard integer DEFAULT 0 NOT NULL, name character varying(128) NOT NULL, @@ -73,6 +72,7 @@ CREATE TABLE identities ( html_signature integer DEFAULT 0 NOT NULL ); +CREATE INDEX identities_user_id_idx ON identities (user_id); -- @@ -94,7 +94,7 @@ CREATE SEQUENCE contact_ids CREATE TABLE contacts ( contact_id integer DEFAULT nextval('contact_ids'::text) PRIMARY KEY, - user_id integer NOT NULL REFERENCES users (user_id), + user_id integer NOT NULL REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE, changed timestamp with time zone DEFAULT now() NOT NULL, del integer DEFAULT 0 NOT NULL, name character varying(128) DEFAULT ''::character varying NOT NULL, @@ -104,7 +104,7 @@ CREATE TABLE contacts ( vcard text ); - +CREATE INDEX contacts_user_id_idx ON contacts (user_id); -- -- Sequence "cache_ids" @@ -124,14 +124,14 @@ CREATE SEQUENCE cache_ids CREATE TABLE "cache" ( cache_id integer DEFAULT nextval('cache_ids'::text) PRIMARY KEY, - user_id integer NOT NULL REFERENCES users (user_id), + user_id integer NOT NULL REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE, session_id character varying(40) REFERENCES "session" (sess_id), cache_key character varying(128) DEFAULT ''::character varying NOT NULL, created timestamp with time zone DEFAULT now() NOT NULL, data text NOT NULL ); - +CREATE INDEX cache_user_id_idx ON "cache" (user_id, cache_key); -- -- Sequence "message_ids" @@ -151,7 +151,7 @@ CREATE SEQUENCE message_ids CREATE TABLE "messages" ( message_id integer DEFAULT nextval('message_ids'::text) PRIMARY KEY, - user_id integer NOT NULL REFERENCES users (user_id), + user_id integer NOT NULL REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE, del integer DEFAULT 0 NOT NULL, cache_key character varying(128) DEFAULT ''::character varying NOT NULL, created timestamp with time zone DEFAULT now() NOT NULL, diff --git a/SQL/postgres.update.sql b/SQL/postgres.update.sql index 0d63cf934..ff1ce12e4 100644 --- a/SQL/postgres.update.sql +++ b/SQL/postgres.update.sql @@ -1,12 +1,16 @@ --- RoundCube Webmail update script for Postres databases --- Updates from version 0.1-beta and older +-- RoundCube Webmail update script for Postgres databases +-- Updates from version 0.1-stable to 0.1.1 -ALTER TABLE "messages" DROP body; -ALTER TABLE "messages" ADD structure TEXT; -ALTER TABLE "messages" ADD UNIQUE (user_id, cache_key, uid); - -ALTER TABLE "identities" ADD html_signature INTEGER; -ALTER TABLE "identities" ALTER html_signature SET DEFAULT 0; -UPDATE identities SET html_signature = 0; -ALTER TABLE "identities" ALTER html_signature SET NOT NULL; +CREATE INDEX cache_user_id_idx ON cache (user_id, cache_key); +CREATE INDEX contacts_user_id_idx ON contacts (user_id); +CREATE INDEX identities_user_id_idx ON identities (user_id); +-- added ON DELETE/UPDATE actions +ALTER TABLE messages DROP CONSTRAINT messages_user_id_fkey; +ALTER TABLE messages ADD FOREIGN KEY (user_id) REFERENCES users(user_id) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE identities DROP CONSTRAINT identities_user_id_fkey; +ALTER TABLE identities ADD FOREIGN KEY (user_id) REFERENCES users(user_id) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE contacts DROP CONSTRAINT contacts_user_id_fkey; +ALTER TABLE contacts ADD FOREIGN KEY (user_id) REFERENCES users(user_id) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE cache DROP CONSTRAINT cache_user_id_fkey; +ALTER TABLE cache ADD FOREIGN KEY (user_id) REFERENCES users(user_id) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/SQL/sqlite.initial.sql b/SQL/sqlite.initial.sql index 4ae752983..041696b1d 100644 --- a/SQL/sqlite.initial.sql +++ b/SQL/sqlite.initial.sql @@ -1,5 +1,5 @@ -- RoundCube Webmail initial database structure --- Version 0.1-rc1 +-- Version 0.1 -- -- -------------------------------------------------------- @@ -17,9 +17,7 @@ CREATE TABLE cache ( data longtext NOT NULL ); -CREATE INDEX ix_cache_user_id ON cache(user_id); -CREATE INDEX ix_cache_cache_key ON cache(cache_key); -CREATE INDEX ix_cache_session_id ON cache(session_id); +CREATE INDEX ix_cache_user_cache_key ON cache(user_id, cache_key); -- -------------------------------------------------------- @@ -82,7 +80,6 @@ CREATE TABLE users ( preferences text NOT NULL default '' ); - -- -------------------------------------------------------- -- @@ -115,14 +112,11 @@ CREATE TABLE messages ( subject varchar(255) NOT NULL default '', "from" varchar(255) NOT NULL default '', "to" varchar(255) NOT NULL default '', - cc varchar(255) NOT NULL default '', - date datetime NOT NULL default '0000-00-00 00:00:00', + "cc" varchar(255) NOT NULL default '', + "date" datetime NOT NULL default '0000-00-00 00:00:00', size integer NOT NULL default '0', headers text NOT NULL, structure text ); -CREATE INDEX ix_messages_user_id ON messages(user_id); -CREATE INDEX ix_messages_cache_key ON messages(cache_key); -CREATE INDEX ix_messages_idx ON messages(idx); -CREATE INDEX ix_messages_uid ON messages(uid); +CREATE INDEX ix_messages_user_cache_uid ON messages(user_id,cache_key,uid); diff --git a/SQL/sqlite.update.sql b/SQL/sqlite.update.sql index e725729ad..f609a3693 100644 --- a/SQL/sqlite.update.sql +++ b/SQL/sqlite.update.sql @@ -1,5 +1,5 @@ -- RoundCube Webmail update script for SQLite databases --- Updates from version 0.1-beta2 and older +-- Updates from version 0.1-stable to 0.1.1 DROP TABLE messages; @@ -14,14 +14,11 @@ CREATE TABLE messages ( subject varchar(255) NOT NULL default '', "from" varchar(255) NOT NULL default '', "to" varchar(255) NOT NULL default '', - cc varchar(255) NOT NULL default '', - date datetime NOT NULL default '0000-00-00 00:00:00', + "cc" varchar(255) NOT NULL default '', + "date" datetime NOT NULL default '0000-00-00 00:00:00', size integer NOT NULL default '0', headers text NOT NULL, structure text ); -CREATE INDEX ix_messages_user_id ON messages(user_id); -CREATE INDEX ix_messages_cache_key ON messages(cache_key); -CREATE INDEX ix_messages_idx ON messages(idx); -CREATE INDEX ix_messages_uid ON messages(uid); +CREATE INDEX ix_messages_user_cache_uid ON messages(user_id,cache_key,uid); |