Add unique index to room_aliases, remove duplicates on upgrade. Convert some columns back to TEXT from bytea

pull/123/head
Erik Johnston 2015-04-17 11:10:20 +01:00
parent e1c0970c11
commit 0ec346d942
7 changed files with 19 additions and 4 deletions

View File

@ -0,0 +1,3 @@
CREATE INDEX IF NOT EXISTS room_aliases_id ON room_aliases(room_id);
CREATE INDEX IF NOT EXISTS room_alias_servers_alias ON room_alias_servers(room_alias);

View File

@ -70,3 +70,11 @@ DROP INDEX IF EXISTS presence_list_observers;
CREATE UNIQUE INDEX presence_list_observers ON presence_list(
user_id, observed_user_id
);
--
DELETE FROM room_aliases WHERE rowid not in (
SELECT MIN(rowid) FROM room_aliases GROUP BY room_alias
);
DROP INDEX IF EXISTS room_aliases_id;
CREATE INDEX room_aliases_id ON room_aliases(room_id);

View File

@ -33,7 +33,7 @@ CREATE TABLE IF NOT EXISTS sent_transactions(
transaction_id VARCHAR(150),
destination VARCHAR(150),
response_code INTEGER DEFAULT 0,
response_json bytea,
response_json TEXT,
ts BIGINT
);

View File

@ -35,7 +35,7 @@ CREATE TABLE IF NOT EXISTS user_ips (
access_token VARCHAR(150) NOT NULL,
device_id VARCHAR(150),
ip VARCHAR(150) NOT NULL,
user_agent VARCHAR(150) NOT NULL,
user_agent TEXT NOT NULL,
last_seen BIGINT NOT NULL,
UNIQUE (user, access_token, ip, user_agent)
);

View File

@ -19,7 +19,11 @@ CREATE TABLE IF NOT EXISTS room_aliases(
UNIQUE (room_alias)
);
CREATE INDEX room_aliases_id ON room_aliases(room_id);
CREATE TABLE IF NOT EXISTS room_alias_servers(
room_alias VARCHAR(150) NOT NULL,
server VARCHAR(150) NOT NULL
);
CREATE INDEX room_alias_servers_alias ON room_alias_servers(room_alias);

View File

@ -33,7 +33,7 @@ CREATE TABLE IF NOT EXISTS sent_transactions(
transaction_id VARCHAR(150),
destination VARCHAR(150),
response_code INTEGER DEFAULT 0,
response_json bytea,
response_json TEXT,
ts BIGINT
);

View File

@ -34,7 +34,7 @@ CREATE TABLE IF NOT EXISTS user_ips (
access_token VARCHAR(150) NOT NULL,
device_id VARCHAR(150),
ip VARCHAR(150) NOT NULL,
user_agent VARCHAR(150) NOT NULL,
user_agent TEXT NOT NULL,
last_seen BIGINT NOT NULL
);