path: root/util
diff options
authorYorhel <>2010-01-26 19:46:32 +0100
committerYorhel <>2010-01-26 19:46:32 +0100
commit38174567d7f68a2751426c0fadcda5eca1bd6861 (patch)
tree1d6832acd003ae2e0018ea47408319957dc5ef4c /util
parent4dfb556ecc621b1983d7ad4154db202ec7530e44 (diff)
Keep track of when a session has last been used
If we're going to automatically remove older sessions, it would make more sense to remove unused sessions, rather than old sessions that are still in use. But we first need to keep track of when a session has last been used to do so...
Diffstat (limited to 'util')
2 files changed, 5 insertions, 0 deletions
diff --git a/util/sql/schema.sql b/util/sql/schema.sql
index f345cffd..f0091929 100644
--- a/util/sql/schema.sql
+++ b/util/sql/schema.sql
@@ -173,6 +173,7 @@ CREATE TABLE sessions (
uid integer NOT NULL,
token bytea NOT NULL,
expiration timestamptz NOT NULL DEFAULT (now() + '1 year'::interval),
+ lastused timestamptz NOT NULL DEFAULT NOW(),
PRIMARY KEY (uid, token)
diff --git a/util/updates/update_2.11.sql b/util/updates/update_2.11.sql
index bf999cdc..09efd7d6 100644
--- a/util/updates/update_2.11.sql
+++ b/util/updates/update_2.11.sql
@@ -81,3 +81,7 @@ UNION SELECT 'r', COUNT(*) FROM (SELECT tmp_edit_hidlock('r', id) FROM releases
UNION SELECT 'p', COUNT(*) FROM (SELECT tmp_edit_hidlock('p', id) FROM producers WHERE hidden OR locked) x;
DROP FUNCTION tmp_edit_hidlock(text, integer);
+-- keep track of when a session is last used
+ALTER TABLE sessions ADD COLUMN lastused timestamptz NOT NULL DEFAULT NOW();