diff options
Diffstat (limited to 'SQL')
-rw-r--r-- | SQL/mssql.initial.sql | 15 | ||||
-rw-r--r-- | SQL/mssql.upgrade.sql | 9 | ||||
-rw-r--r-- | SQL/mysql.initial.sql | 11 | ||||
-rw-r--r-- | SQL/mysql.update.sql | 6 | ||||
-rw-r--r-- | SQL/postgres.initial.sql | 16 | ||||
-rw-r--r-- | SQL/postgres.update.sql | 8 | ||||
-rw-r--r-- | SQL/sqlite.initial.sql | 4 | ||||
-rw-r--r-- | SQL/sqlite.update.sql | 45 |
8 files changed, 76 insertions, 38 deletions
diff --git a/SQL/mssql.initial.sql b/SQL/mssql.initial.sql index 2ac6aa63e..85b8e4ef6 100644 --- a/SQL/mssql.initial.sql +++ b/SQL/mssql.initial.sql @@ -1,5 +1,4 @@ CREATE TABLE [dbo].[cache] (
- [cache_id] [int] IDENTITY (1, 1) NOT NULL ,
[user_id] [int] NOT NULL ,
[cache_key] [varchar] (128) COLLATE Latin1_General_CI_AI NOT NULL ,
[created] [datetime] NOT NULL ,
@@ -93,7 +92,6 @@ CREATE TABLE [dbo].[users] ( [user_id] [int] IDENTITY (1, 1) NOT NULL ,
[username] [varchar] (128) COLLATE Latin1_General_CI_AI NOT NULL ,
[mail_host] [varchar] (128) COLLATE Latin1_General_CI_AI NOT NULL ,
- [alias] [varchar] (128) COLLATE Latin1_General_CI_AI NOT NULL ,
[created] [datetime] NOT NULL ,
[last_login] [datetime] NULL ,
[language] [varchar] (5) COLLATE Latin1_General_CI_AI NULL ,
@@ -117,13 +115,6 @@ CREATE TABLE [dbo].[searches] ( ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
-ALTER TABLE [dbo].[cache] WITH NOCHECK ADD
- PRIMARY KEY CLUSTERED
- (
- [cache_id]
- ) ON [PRIMARY]
-GO
-
ALTER TABLE [dbo].[cache_index] WITH NOCHECK ADD
PRIMARY KEY CLUSTERED
(
@@ -282,6 +273,8 @@ GO CREATE INDEX [IX_identities_user_id] ON [dbo].[identities]([user_id]) ON [PRIMARY]
GO
+CREATE INDEX [IX_identities_email] ON [dbo].[identities]([email],[del]) ON [PRIMARY]
+GO
ALTER TABLE [dbo].[session] ADD
CONSTRAINT [DF_session_sess_id] DEFAULT ('') FOR [sess_id],
@@ -295,16 +288,12 @@ GO ALTER TABLE [dbo].[users] ADD
CONSTRAINT [DF_users_username] DEFAULT ('') FOR [username],
CONSTRAINT [DF_users_mail_host] DEFAULT ('') FOR [mail_host],
- CONSTRAINT [DF_users_alias] DEFAULT ('') FOR [alias],
CONSTRAINT [DF_users_created] DEFAULT (getdate()) FOR [created]
GO
CREATE UNIQUE INDEX [IX_users_username] ON [dbo].[users]([username],[mail_host]) ON [PRIMARY]
GO
-CREATE INDEX [IX_users_alias] ON [dbo].[users]([alias]) ON [PRIMARY]
-GO
-
CREATE UNIQUE INDEX [IX_dictionary_user_language] ON [dbo].[dictionary]([user_id],[language]) ON [PRIMARY]
GO
diff --git a/SQL/mssql.upgrade.sql b/SQL/mssql.upgrade.sql index d111ef3e7..26001e713 100644 --- a/SQL/mssql.upgrade.sql +++ b/SQL/mssql.upgrade.sql @@ -261,4 +261,13 @@ ALTER TABLE [dbo].[contacts] ALTER COLUMN [email] [varchar] (8000) COLLATE Latin GO
ALTER TABLE [dbo].[contacts] ADD CONSTRAINT [DF_contacts_email] DEFAULT ('') FOR [email]
GO
+
+-- Updates from version 0.8
+
+ALTER TABLE [dbo].[cache] DROP COLUMN [cache_id]
+GO
+ALTER TABLE [dbo].[users] DROP COLUMN [alias]
+GO
+CREATE INDEX [IX_identities_email] ON [dbo].[identities]([email],[del]) ON [PRIMARY]
+GO
\ No newline at end of file diff --git a/SQL/mysql.initial.sql b/SQL/mysql.initial.sql index b0a7ee7a9..47d9db4a2 100644 --- a/SQL/mysql.initial.sql +++ b/SQL/mysql.initial.sql @@ -22,26 +22,22 @@ CREATE TABLE `users` ( `user_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, `username` varchar(128) BINARY NOT NULL, `mail_host` varchar(128) NOT NULL, - `alias` varchar(128) BINARY NOT NULL, `created` datetime NOT NULL DEFAULT '1000-01-01 00:00:00', `last_login` datetime DEFAULT NULL, `language` varchar(5), `preferences` text, PRIMARY KEY(`user_id`), - UNIQUE `username` (`username`, `mail_host`), - INDEX `alias_index` (`alias`) + UNIQUE `username` (`username`, `mail_host`) ) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */; -- Table structure for table `cache` CREATE TABLE `cache` ( - `cache_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, + `user_id` int(10) UNSIGNED NOT NULL, `cache_key` varchar(128) /*!40101 CHARACTER SET ascii COLLATE ascii_general_ci */ NOT NULL , `created` datetime NOT NULL DEFAULT '1000-01-01 00:00:00', `data` longtext NOT NULL, - `user_id` int(10) UNSIGNED NOT NULL, - PRIMARY KEY(`cache_id`), CONSTRAINT `user_id_fk_cache` FOREIGN KEY (`user_id`) REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE, INDEX `created_index` (`created`), @@ -158,7 +154,8 @@ CREATE TABLE `identities` ( PRIMARY KEY(`identity_id`), CONSTRAINT `user_id_fk_identities` FOREIGN KEY (`user_id`) REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE, - INDEX `user_identities_index` (`user_id`, `del`) + INDEX `user_identities_index` (`user_id`, `del`), + INDEX `email_identities_index` (`email`, `del`) ) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */; diff --git a/SQL/mysql.update.sql b/SQL/mysql.update.sql index 300ceb59d..237aa3e38 100644 --- a/SQL/mysql.update.sql +++ b/SQL/mysql.update.sql @@ -239,3 +239,9 @@ ALTER TABLE `identities` ALTER `user_id` DROP DEFAULT; ALTER TABLE `searches` ALTER `user_id` DROP DEFAULT; /*!40014 SET FOREIGN_KEY_CHECKS=1 */; + +-- Updates from version 0.8 + +ALTER TABLE `cache` DROP COLUMN `cache_id`; +ALTER TABLE `users` DROP COLUMN `alias`; +ALTER TABLE `identities` ADD INDEX `email_identities_index` (`email`, `del`); diff --git a/SQL/postgres.initial.sql b/SQL/postgres.initial.sql index e12a9978a..f7b2d96d9 100644 --- a/SQL/postgres.initial.sql +++ b/SQL/postgres.initial.sql @@ -20,7 +20,6 @@ CREATE TABLE users ( user_id integer DEFAULT nextval('user_ids'::text) PRIMARY KEY, username varchar(128) DEFAULT '' NOT NULL, mail_host varchar(128) DEFAULT '' NOT NULL, - alias varchar(128) DEFAULT '' NOT NULL, created timestamp with time zone DEFAULT now() NOT NULL, last_login timestamp with time zone DEFAULT NULL, "language" varchar(5), @@ -28,9 +27,7 @@ CREATE TABLE users ( CONSTRAINT users_username_key UNIQUE (username, mail_host) ); -CREATE INDEX users_alias_id_idx ON users (alias); - -- -- Table "session" -- Name: session; Type: TABLE; Schema: public; Owner: postgres @@ -81,6 +78,7 @@ CREATE TABLE identities ( ); CREATE INDEX identities_user_id_idx ON identities (user_id, del); +CREATE INDEX identities_email_idx ON identities (email, del); -- @@ -160,23 +158,11 @@ CREATE TABLE contactgroupmembers ( CREATE INDEX contactgroupmembers_contact_id_idx ON contactgroupmembers (contact_id); -- --- Sequence "cache_ids" --- Name: cache_ids; Type: SEQUENCE; Schema: public; Owner: postgres --- - -CREATE SEQUENCE cache_ids - INCREMENT BY 1 - NO MAXVALUE - NO MINVALUE - CACHE 1; - --- -- Table "cache" -- Name: cache; Type: TABLE; Schema: public; Owner: postgres -- CREATE TABLE "cache" ( - cache_id integer DEFAULT nextval('cache_ids'::text) PRIMARY KEY, user_id integer NOT NULL REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE, cache_key varchar(128) DEFAULT '' NOT NULL, diff --git a/SQL/postgres.update.sql b/SQL/postgres.update.sql index 7e9d34fa9..11ab93bfc 100644 --- a/SQL/postgres.update.sql +++ b/SQL/postgres.update.sql @@ -175,3 +175,11 @@ ALTER TABLE "session" ALTER sess_id TYPE varchar(128); DROP INDEX contacts_user_id_idx; CREATE INDEX contacts_user_id_idx ON contacts USING btree (user_id, del); ALTER TABLE contacts ALTER email TYPE text; + +-- Updates from version 0.8 + +ALTER TABLE cache DROP COLUMN cache_id; +DROP SEQUENCE cache_ids; + +ALTER TABLE users DROP COLUMN alias; +CREATE INDEX identities_email_idx ON identities (email, del); diff --git a/SQL/sqlite.initial.sql b/SQL/sqlite.initial.sql index dafb5a15d..f5b5615d8 100644 --- a/SQL/sqlite.initial.sql +++ b/SQL/sqlite.initial.sql @@ -5,7 +5,6 @@ -- CREATE TABLE cache ( - cache_id integer NOT NULL PRIMARY KEY, user_id integer NOT NULL default 0, cache_key varchar(128) NOT NULL default '', created datetime NOT NULL default '0000-00-00 00:00:00', @@ -81,6 +80,7 @@ CREATE TABLE identities ( ); CREATE INDEX ix_identities_user_id ON identities(user_id, del); +CREATE INDEX ix_identities_email ON identities(email, del); -- -------------------------------------------------------- @@ -93,7 +93,6 @@ CREATE TABLE users ( user_id integer NOT NULL PRIMARY KEY, username varchar(128) NOT NULL default '', mail_host varchar(128) NOT NULL default '', - alias varchar(128) NOT NULL default '', created datetime NOT NULL default '0000-00-00 00:00:00', last_login datetime DEFAULT NULL, language varchar(5), @@ -101,7 +100,6 @@ CREATE TABLE users ( ); CREATE UNIQUE INDEX ix_users_username ON users(username, mail_host); -CREATE INDEX ix_users_alias ON users(alias); -- -------------------------------------------------------- diff --git a/SQL/sqlite.update.sql b/SQL/sqlite.update.sql index 9f410fb13..72a29e9ae 100644 --- a/SQL/sqlite.update.sql +++ b/SQL/sqlite.update.sql @@ -333,3 +333,48 @@ INSERT INTO contacts (contact_id, user_id, changed, del, name, email, firstname, CREATE INDEX ix_contacts_user_id ON contacts(user_id, del); DROP TABLE contacts_tmp; + +-- Updates from version 0.8 + +DROP TABLE cache; +CREATE TABLE cache ( + user_id integer NOT NULL default 0, + cache_key varchar(128) NOT NULL default '', + created datetime NOT NULL default '0000-00-00 00:00:00', + data text NOT NULL +); + +CREATE INDEX ix_cache_user_cache_key ON cache(user_id, cache_key); +CREATE INDEX ix_cache_created ON cache(created); + +CREATE TABLE tmp_users ( + user_id integer NOT NULL PRIMARY KEY, + username varchar(128) NOT NULL default '', + mail_host varchar(128) NOT NULL default '', + created datetime NOT NULL default '0000-00-00 00:00:00', + last_login datetime DEFAULT NULL, + language varchar(5), + preferences text NOT NULL default '' +); + +INSERT INTO tmp_users (user_id, username, mail_host, created, last_login, language, preferences) + SELECT user_id, username, mail_host, created, last_login, language, preferences FROM users; + +DROP TABLE users; + +CREATE TABLE users ( + user_id integer NOT NULL PRIMARY KEY, + username varchar(128) NOT NULL default '', + mail_host varchar(128) NOT NULL default '', + created datetime NOT NULL default '0000-00-00 00:00:00', + last_login datetime DEFAULT NULL, + language varchar(5), + preferences text NOT NULL default '' +); + +INSERT INTO users (user_id, username, mail_host, created, last_login, language, preferences) + SELECT user_id, username, mail_host, created, last_login, language, preferences FROM tmp_users; + +CREATE UNIQUE INDEX ix_users_username ON users(username, mail_host); + +CREATE INDEX ix_identities_email ON identities(email, del); |