summaryrefslogtreecommitdiff
path: root/SQL
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2008-11-21 14:33:58 +0000
committeralecpl <alec@alec.pl>2008-11-21 14:33:58 +0000
commitbe7d3b6918ff90757d10804ac914edb5a65f4828 (patch)
treeabc0e0ab2a4876a05692503d748f3370e8999aa2 /SQL
parentbd0c2b0a341c5440c66f9b0e9d2ad2b869401f03 (diff)
- Fix 'cache' table cleanup on session destroy (#1485516)
Diffstat (limited to 'SQL')
-rw-r--r--SQL/mysql.update.sql8
-rw-r--r--SQL/mysql5.initial.sql4
-rw-r--r--SQL/postgres.initial.sql3
-rw-r--r--SQL/postgres.update.sql6
4 files changed, 20 insertions, 1 deletions
diff --git a/SQL/mysql.update.sql b/SQL/mysql.update.sql
index ae6fb7533..f88a6c4db 100644
--- a/SQL/mysql.update.sql
+++ b/SQL/mysql.update.sql
@@ -30,3 +30,11 @@ ALTER TABLE `identities`
ALTER TABLE `messages`
ADD INDEX `created_index` (`created`);
+
+-- Updates from version 0.2-beta (InnoDB only)
+
+ALTER TABLE `cache`
+ ADD CONSTRAINT `session_id_fk_cache` FOREIGN KEY (`session_id`)
+ REFERENCES `session`(`sess_id`)
+ ON DELETE CASCADE
+ ON UPDATE CASCADE;
diff --git a/SQL/mysql5.initial.sql b/SQL/mysql5.initial.sql
index f9d647b80..e01f2a6b1 100644
--- a/SQL/mysql5.initial.sql
+++ b/SQL/mysql5.initial.sql
@@ -77,6 +77,10 @@ CREATE TABLE `cache` (
CONSTRAINT `user_id_fk_cache` FOREIGN KEY (`user_id`)
REFERENCES `users`(`user_id`)
ON DELETE CASCADE
+ ON UPDATE CASCADE,
+ CONSTRAINT `session_id_fk_cache` FOREIGN KEY (`session_id`)
+ REFERENCES `session`(`sess_id`)
+ ON DELETE CASCADE
ON UPDATE CASCADE
) TYPE=INNODB CHARACTER SET utf8 COLLATE utf8_general_ci;
diff --git a/SQL/postgres.initial.sql b/SQL/postgres.initial.sql
index 88f12af66..e53caa187 100644
--- a/SQL/postgres.initial.sql
+++ b/SQL/postgres.initial.sql
@@ -128,13 +128,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) ON DELETE CASCADE ON UPDATE CASCADE,
- session_id character varying(40) REFERENCES "session" (sess_id),
+ session_id character varying(40) REFERENCES "session" (sess_id) ON DELETE CASCADE ON UPDATE CASCADE,
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);
+CREATE INDEX cache_session_id_idx ON "cache" (session_id);
--
-- Sequence "message_ids"
diff --git a/SQL/postgres.update.sql b/SQL/postgres.update.sql
index dfc282b4a..fdd7f0f5e 100644
--- a/SQL/postgres.update.sql
+++ b/SQL/postgres.update.sql
@@ -21,3 +21,9 @@ ALTER TABLE cache ADD FOREIGN KEY (user_id) REFERENCES users(user_id) ON DELETE
-- Updates from version 0.2-alpha
CREATE INDEX messages_created_idx ON messages (created);
+
+-- Updates from version 0.2-beta
+
+ALTER TABLE cache DROP CONSTRAINT cache_session_id_fkey;
+ALTER TABLE cache ADD FOREIGN KEY (session_id) REFERENCES session(sess_id) ON DELETE CASCADE ON UPDATE CASCADE;
+CREATE INDEX cache_session_id_idx ON "cache" (session_id);