Rename user_ips.user -> user_id

This commit is contained in:
Erik Johnston 2015-04-14 13:54:09 +01:00
parent 58d8339966
commit 5a95cd4442
3 changed files with 8 additions and 8 deletions

View file

@ -107,7 +107,7 @@ class DataStore(RoomMemberStore, RoomStore,
yield self._simple_upsert( yield self._simple_upsert(
"user_ips", "user_ips",
keyvalues={ keyvalues={
"user": user.to_string(), "user_id": user.to_string(),
"access_token": access_token, "access_token": access_token,
"ip": ip, "ip": ip,
"user_agent": user_agent, "user_agent": user_agent,
@ -122,7 +122,7 @@ class DataStore(RoomMemberStore, RoomStore,
def get_user_ip_and_agents(self, user): def get_user_ip_and_agents(self, user):
return self._simple_select_list( return self._simple_select_list(
table="user_ips", table="user_ips",
keyvalues={"user": user.to_string()}, keyvalues={"user_id": user.to_string()},
retcols=[ retcols=[
"device_id", "access_token", "ip", "user_agent", "last_seen" "device_id", "access_token", "ip", "user_agent", "last_seen"
], ],

View file

@ -36,7 +36,7 @@ ALTER TABLE new_users RENAME TO users;
-- Remove UNIQUE constraint from `user_ips` table -- Remove UNIQUE constraint from `user_ips` table
CREATE TABLE IF NOT EXISTS new_user_ips ( CREATE TABLE IF NOT EXISTS new_user_ips (
user VARCHAR(150) NOT NULL, user_id VARCHAR(150) NOT NULL,
access_token VARCHAR(150) NOT NULL, access_token VARCHAR(150) NOT NULL,
device_id VARCHAR(150), device_id VARCHAR(150),
ip VARCHAR(150) NOT NULL, ip VARCHAR(150) NOT NULL,
@ -51,6 +51,6 @@ DROP TABLE user_ips;
ALTER TABLE new_user_ips RENAME TO user_ips; ALTER TABLE new_user_ips RENAME TO user_ips;
CREATE INDEX IF NOT EXISTS user_ips_user ON user_ips(user); CREATE INDEX IF NOT EXISTS user_ips_user ON user_ips(user_id);
CREATE INDEX IF NOT EXISTS user_ips_user_ip ON user_ips(user, access_token, ip); CREATE INDEX IF NOT EXISTS user_ips_user_ip ON user_ips(user_id, access_token, ip);

View file

@ -30,7 +30,7 @@ CREATE TABLE IF NOT EXISTS access_tokens(
); );
CREATE TABLE IF NOT EXISTS user_ips ( CREATE TABLE IF NOT EXISTS user_ips (
user VARCHAR(150) NOT NULL, user_id VARCHAR(150) NOT NULL,
access_token VARCHAR(150) NOT NULL, access_token VARCHAR(150) NOT NULL,
device_id VARCHAR(150), device_id VARCHAR(150),
ip VARCHAR(150) NOT NULL, ip VARCHAR(150) NOT NULL,
@ -38,5 +38,5 @@ CREATE TABLE IF NOT EXISTS user_ips (
last_seen BIGINT NOT NULL last_seen BIGINT NOT NULL
); );
CREATE INDEX IF NOT EXISTS user_ips_user ON user_ips(user); CREATE INDEX user_ips_user ON user_ips(user_id);
CREATE INDEX IF NOT EXISTS user_ips_user_ip ON user_ips(user, access_token, ip); CREATE INDEX user_ips_user_ip ON user_ips(user_id, access_token, ip);