summary refs log tree commit diff
path: root/synapse/storage/schema
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2014-09-29 13:35:15 +0100
committerErik Johnston <erik@matrix.org>2014-09-29 13:35:15 +0100
commitf7d80930f21190355733da9ba7ab5068ce0702a8 (patch)
treecf66b7e28cfa49006c8e8ddae610f8371d2f7744 /synapse/storage/schema
parentTrack the IP users connect with. Add an admin column to users table. (diff)
downloadsynapse-f7d80930f21190355733da9ba7ab5068ce0702a8.tar.xz
SYN-48: Track User-Agents as well as IPs for client devices.
Diffstat (limited to 'synapse/storage/schema')
-rw-r--r--synapse/storage/schema/delta/v5.sql4
-rw-r--r--synapse/storage/schema/users.sql4
2 files changed, 6 insertions, 2 deletions
diff --git a/synapse/storage/schema/delta/v5.sql b/synapse/storage/schema/delta/v5.sql
index 380eec6f35..f5a667a250 100644
--- a/synapse/storage/schema/delta/v5.sql
+++ b/synapse/storage/schema/delta/v5.sql
@@ -3,7 +3,9 @@ CREATE TABLE IF NOT EXISTS user_ips (
     user TEXT NOT NULL,
     access_token TEXT NOT NULL,
     ip TEXT NOT NULL,
-    CONSTRAINT user_ip UNIQUE (user, access_token, ip) ON CONFLICT IGNORE
+    user_agent TEXT NOT NULL,
+    last_used INTEGER NOT NULL,
+    CONSTRAINT user_ip UNIQUE (user, access_token, ip, user_agent) ON CONFLICT REPLACE
 );
 
 CREATE INDEX IF NOT EXISTS user_ips_user ON user_ips(user);
diff --git a/synapse/storage/schema/users.sql b/synapse/storage/schema/users.sql
index 89eab8babe..d96dd9f075 100644
--- a/synapse/storage/schema/users.sql
+++ b/synapse/storage/schema/users.sql
@@ -35,7 +35,9 @@ CREATE TABLE IF NOT EXISTS user_ips (
     user TEXT NOT NULL,
     access_token TEXT NOT NULL,
     ip TEXT NOT NULL,
-    CONSTRAINT user_ip UNIQUE (user, access_token, ip) ON CONFLICT IGNORE
+    user_agent TEXT NOT NULL,
+    last_used INTEGER NOT NULL,
+    CONSTRAINT user_ip UNIQUE (user, access_token, ip, user_agent) ON CONFLICT REPLACE
 );
 
 CREATE INDEX IF NOT EXISTS user_ips_user ON user_ips(user);