diff options
author | alecpl <alec@alec.pl> | 2010-10-06 13:00:12 +0000 |
---|---|---|
committer | alecpl <alec@alec.pl> | 2010-10-06 13:00:12 +0000 |
commit | ace511a771656c983046919333cee501339c98a1 (patch) | |
tree | e0cf919256f349da6ee939f582fd04428cc8d6d4 /SQL | |
parent | fec0704423075a1a5199d1c455a3ee0f7ea00ab3 (diff) |
- Add unique index on users.username+users.mail_host
Diffstat (limited to 'SQL')
-rw-r--r-- | SQL/mssql.initial.sql | 2 | ||||
-rw-r--r-- | SQL/mssql.upgrade.sql | 7 | ||||
-rw-r--r-- | SQL/mysql.initial.sql | 2 | ||||
-rw-r--r-- | SQL/mysql.update.sql | 6 | ||||
-rw-r--r-- | SQL/postgres.initial.sql | 10 | ||||
-rw-r--r-- | SQL/postgres.update.sql | 8 | ||||
-rw-r--r-- | SQL/sqlite.initial.sql | 2 | ||||
-rw-r--r-- | SQL/sqlite.update.sql | 6 |
8 files changed, 34 insertions, 9 deletions
diff --git a/SQL/mssql.initial.sql b/SQL/mssql.initial.sql index 553e68a48..6b031a256 100644 --- a/SQL/mssql.initial.sql +++ b/SQL/mssql.initial.sql @@ -255,7 +255,7 @@ ALTER TABLE [dbo].[users] ADD CONSTRAINT [DF_users_created] DEFAULT (getdate()) FOR [created]
GO
-CREATE INDEX [IX_users_username] ON [dbo].[users]([username]) ON [PRIMARY]
+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]
diff --git a/SQL/mssql.upgrade.sql b/SQL/mssql.upgrade.sql index 1aa771b1f..6b3cd6d03 100644 --- a/SQL/mssql.upgrade.sql +++ b/SQL/mssql.upgrade.sql @@ -87,3 +87,10 @@ ALTER TABLE [dbo].[contactgroups] ADD CONSTRAINT [FK_contactgroups_user_id] ON DELETE CASCADE ON UPDATE CASCADE
GO
+-- Updates from version 0.4.2
+
+DROP INDEX [IX_users_username]
+GO
+CREATE UNIQUE INDEX [IX_users_username] ON [dbo].[users]([username],[mail_host]) ON [PRIMARY]
+GO
+ diff --git a/SQL/mysql.initial.sql b/SQL/mysql.initial.sql index fdab11505..456a48313 100644 --- a/SQL/mysql.initial.sql +++ b/SQL/mysql.initial.sql @@ -28,7 +28,7 @@ CREATE TABLE `users` ( `language` varchar(5), `preferences` text, PRIMARY KEY(`user_id`), - INDEX `username_index` (`username`), + UNIQUE `username` (`username`, `mail_host`), INDEX `alias_index` (`alias`) ) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */; diff --git a/SQL/mysql.update.sql b/SQL/mysql.update.sql index 28ebf6f49..b9ab59ea9 100644 --- a/SQL/mysql.update.sql +++ b/SQL/mysql.update.sql @@ -123,3 +123,9 @@ CREATE TABLE `contactgroupmembers` ( ALTER TABLE `users` CHANGE `last_login` `last_login` datetime DEFAULT NULL; UPDATE `users` SET `last_login` = NULL WHERE `last_login` = '1000-01-01 00:00:00'; + +-- Updates from version 0.4.2 + +ALTER TABLE `users` DROP INDEX `username_index`; +ALTER TABLE `users` ADD UNIQUE `username` (`username`, `mail_host`); + diff --git a/SQL/postgres.initial.sql b/SQL/postgres.initial.sql index ac59efb18..84a9afd40 100644 --- a/SQL/postgres.initial.sql +++ b/SQL/postgres.initial.sql @@ -24,10 +24,10 @@ CREATE TABLE users ( created timestamp with time zone DEFAULT now() NOT NULL, last_login timestamp with time zone DEFAULT NULL, "language" varchar(5), - preferences text DEFAULT ''::text NOT NULL + preferences text DEFAULT ''::text NOT NULL, + UNIQUE (username, mail_host) ); -CREATE INDEX users_username_id_idx ON users (username); CREATE INDEX users_alias_id_idx ON users (alias); @@ -146,7 +146,7 @@ CREATE INDEX contactgroups_user_id_idx ON contactgroups (user_id, del); -- Table "contactgroupmembers" -- Name: contactgroupmembers; Type: TABLE; Schema: public; Owner: postgres -- - + CREATE TABLE contactgroupmembers ( contactgroup_id integer NOT NULL REFERENCES contactgroups(contactgroup_id) ON DELETE CASCADE ON UPDATE CASCADE, @@ -216,9 +216,9 @@ CREATE TABLE messages ( date timestamp with time zone NOT NULL, size integer DEFAULT 0 NOT NULL, headers text NOT NULL, - structure text + structure text, + UNIQUE (user_id, cache_key, uid) ); -ALTER TABLE messages ADD UNIQUE (user_id, cache_key, uid); CREATE INDEX messages_index_idx ON messages (user_id, cache_key, idx); CREATE INDEX messages_created_idx ON messages (created); diff --git a/SQL/postgres.update.sql b/SQL/postgres.update.sql index 1ef93d8b6..99b9c0e29 100644 --- a/SQL/postgres.update.sql +++ b/SQL/postgres.update.sql @@ -56,7 +56,7 @@ CREATE SEQUENCE contactgroups_ids NO MAXVALUE NO MINVALUE CACHE 1; - + CREATE TABLE contactgroups ( contactgroup_id integer DEFAULT nextval('contactgroups_ids'::text) PRIMARY KEY, user_id integer NOT NULL @@ -81,3 +81,9 @@ CREATE TABLE contactgroupmembers ( ALTER TABLE users ALTER last_login DROP NOT NULL; ALTER TABLE users ALTER last_login SET DEFAULT NULL; + +-- Updates from version 0.4.2 + +DROP INDEX users_username_id_idx; +ALTER TABLE users ADD UNIQUE (username, mail_host); + diff --git a/SQL/sqlite.initial.sql b/SQL/sqlite.initial.sql index e7faeedea..ea7650cb7 100644 --- a/SQL/sqlite.initial.sql +++ b/SQL/sqlite.initial.sql @@ -97,7 +97,7 @@ CREATE TABLE users ( preferences text NOT NULL default '' ); -CREATE INDEX ix_users_username ON users(username); +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 2db782153..78e283e2d 100644 --- a/SQL/sqlite.update.sql +++ b/SQL/sqlite.update.sql @@ -140,3 +140,9 @@ INSERT INTO users (user_id, username, mail_host, alias, created, last_login, lan CREATE INDEX ix_users_username ON users(username); CREATE INDEX ix_users_alias ON users(alias); DROP TABLE tmp_users; + +-- Updates from version 0.4.2 + +DROP INDEX ix_users_username; +CREATE UNIQUE INDEX ix_users_username ON users(username, mail_host); + |