diff options
author | Erik Johnston <erik@matrix.org> | 2019-10-21 12:56:42 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2019-10-21 16:05:06 +0100 |
commit | c66a06ac6b69b0a03f5c6284ded980399e9df94e (patch) | |
tree | 01dfd3b9098a9ace759403744d122c18efbd97ff /synapse/storage/schema/delta/16 | |
parent | Merge branch 'master' into develop (diff) | |
download | synapse-c66a06ac6b69b0a03f5c6284ded980399e9df94e.tar.xz |
Move storage classes into a main "data store".
This is in preparation for having multiple data stores that offer different functionality, e.g. splitting out state or event storage.
Diffstat (limited to 'synapse/storage/schema/delta/16')
6 files changed, 0 insertions, 146 deletions
diff --git a/synapse/storage/schema/delta/16/events_order_index.sql b/synapse/storage/schema/delta/16/events_order_index.sql deleted file mode 100644 index a48f215170..0000000000 --- a/synapse/storage/schema/delta/16/events_order_index.sql +++ /dev/null @@ -1,4 +0,0 @@ -CREATE INDEX events_order ON events (topological_ordering, stream_ordering); -CREATE INDEX events_order_room ON events ( - room_id, topological_ordering, stream_ordering -); diff --git a/synapse/storage/schema/delta/16/remote_media_cache_index.sql b/synapse/storage/schema/delta/16/remote_media_cache_index.sql deleted file mode 100644 index 7a15265cb1..0000000000 --- a/synapse/storage/schema/delta/16/remote_media_cache_index.sql +++ /dev/null @@ -1,2 +0,0 @@ -CREATE INDEX IF NOT EXISTS remote_media_cache_thumbnails_media_id - ON remote_media_cache_thumbnails (media_id); \ No newline at end of file diff --git a/synapse/storage/schema/delta/16/remove_duplicates.sql b/synapse/storage/schema/delta/16/remove_duplicates.sql deleted file mode 100644 index 65c97b5e2f..0000000000 --- a/synapse/storage/schema/delta/16/remove_duplicates.sql +++ /dev/null @@ -1,9 +0,0 @@ - - -DELETE FROM event_to_state_groups WHERE state_group not in ( - SELECT MAX(state_group) FROM event_to_state_groups GROUP BY event_id -); - -DELETE FROM event_to_state_groups WHERE rowid not in ( - SELECT MIN(rowid) FROM event_to_state_groups GROUP BY event_id -); diff --git a/synapse/storage/schema/delta/16/room_alias_index.sql b/synapse/storage/schema/delta/16/room_alias_index.sql deleted file mode 100644 index f82486132b..0000000000 --- a/synapse/storage/schema/delta/16/room_alias_index.sql +++ /dev/null @@ -1,3 +0,0 @@ - -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); diff --git a/synapse/storage/schema/delta/16/unique_constraints.sql b/synapse/storage/schema/delta/16/unique_constraints.sql deleted file mode 100644 index 5b8de52c33..0000000000 --- a/synapse/storage/schema/delta/16/unique_constraints.sql +++ /dev/null @@ -1,72 +0,0 @@ - --- We can use SQLite features here, since other db support was only added in v16 - --- -DELETE FROM current_state_events WHERE rowid not in ( - SELECT MIN(rowid) FROM current_state_events GROUP BY event_id -); - -DROP INDEX IF EXISTS current_state_events_event_id; -CREATE UNIQUE INDEX current_state_events_event_id ON current_state_events(event_id); - --- -DELETE FROM room_memberships WHERE rowid not in ( - SELECT MIN(rowid) FROM room_memberships GROUP BY event_id -); - -DROP INDEX IF EXISTS room_memberships_event_id; -CREATE UNIQUE INDEX room_memberships_event_id ON room_memberships(event_id); - --- -DELETE FROM topics WHERE rowid not in ( - SELECT MIN(rowid) FROM topics GROUP BY event_id -); - -DROP INDEX IF EXISTS topics_event_id; -CREATE UNIQUE INDEX topics_event_id ON topics(event_id); - --- -DELETE FROM room_names WHERE rowid not in ( - SELECT MIN(rowid) FROM room_names GROUP BY event_id -); - -DROP INDEX IF EXISTS room_names_id; -CREATE UNIQUE INDEX room_names_id ON room_names(event_id); - --- -DELETE FROM presence WHERE rowid not in ( - SELECT MIN(rowid) FROM presence GROUP BY user_id -); - -DROP INDEX IF EXISTS presence_id; -CREATE UNIQUE INDEX presence_id ON presence(user_id); - --- -DELETE FROM presence_allow_inbound WHERE rowid not in ( - SELECT MIN(rowid) FROM presence_allow_inbound - GROUP BY observed_user_id, observer_user_id -); - -DROP INDEX IF EXISTS presence_allow_inbound_observers; -CREATE UNIQUE INDEX presence_allow_inbound_observers ON presence_allow_inbound( - observed_user_id, observer_user_id -); - --- -DELETE FROM presence_list WHERE rowid not in ( - SELECT MIN(rowid) FROM presence_list - GROUP BY user_id, observed_user_id -); - -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); diff --git a/synapse/storage/schema/delta/16/users.sql b/synapse/storage/schema/delta/16/users.sql deleted file mode 100644 index cd0709250d..0000000000 --- a/synapse/storage/schema/delta/16/users.sql +++ /dev/null @@ -1,56 +0,0 @@ --- Convert `access_tokens`.user from rowids to user strings. --- MUST BE DONE BEFORE REMOVING ID COLUMN FROM USERS TABLE BELOW -CREATE TABLE IF NOT EXISTS new_access_tokens( - id BIGINT UNSIGNED PRIMARY KEY, - user_id TEXT NOT NULL, - device_id TEXT, - token TEXT NOT NULL, - last_used BIGINT UNSIGNED, - UNIQUE(token) -); - -INSERT INTO new_access_tokens - SELECT a.id, u.name, a.device_id, a.token, a.last_used - FROM access_tokens as a - INNER JOIN users as u ON u.id = a.user_id; - -DROP TABLE access_tokens; - -ALTER TABLE new_access_tokens RENAME TO access_tokens; - --- Remove ID column from `users` table -CREATE TABLE IF NOT EXISTS new_users( - name TEXT, - password_hash TEXT, - creation_ts BIGINT UNSIGNED, - admin BOOL DEFAULT 0 NOT NULL, - UNIQUE(name) -); - -INSERT INTO new_users SELECT name, password_hash, creation_ts, admin FROM users; - -DROP TABLE users; - -ALTER TABLE new_users RENAME TO users; - - --- Remove UNIQUE constraint from `user_ips` table -CREATE TABLE IF NOT EXISTS new_user_ips ( - user_id TEXT NOT NULL, - access_token TEXT NOT NULL, - device_id TEXT, - ip TEXT NOT NULL, - user_agent TEXT NOT NULL, - last_seen BIGINT UNSIGNED NOT NULL -); - -INSERT INTO new_user_ips - SELECT user, access_token, device_id, ip, user_agent, last_seen FROM user_ips; - -DROP TABLE user_ips; - -ALTER TABLE new_user_ips RENAME TO user_ips; - -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_id, access_token, ip); - |