summary refs log tree commit diff
path: root/synapse/storage/schema/delta
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2019-10-21 12:56:42 +0100
committerErik Johnston <erik@matrix.org>2019-10-21 16:05:06 +0100
commitc66a06ac6b69b0a03f5c6284ded980399e9df94e (patch)
tree01dfd3b9098a9ace759403744d122c18efbd97ff /synapse/storage/schema/delta
parentMerge branch 'master' into develop (diff)
downloadsynapse-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')
-rw-r--r--synapse/storage/schema/delta/12/v12.sql63
-rw-r--r--synapse/storage/schema/delta/13/v13.sql19
-rw-r--r--synapse/storage/schema/delta/14/v14.sql23
-rw-r--r--synapse/storage/schema/delta/15/appservice_txns.sql31
-rw-r--r--synapse/storage/schema/delta/15/presence_indices.sql2
-rw-r--r--synapse/storage/schema/delta/15/v15.sql24
-rw-r--r--synapse/storage/schema/delta/16/events_order_index.sql4
-rw-r--r--synapse/storage/schema/delta/16/remote_media_cache_index.sql2
-rw-r--r--synapse/storage/schema/delta/16/remove_duplicates.sql9
-rw-r--r--synapse/storage/schema/delta/16/room_alias_index.sql3
-rw-r--r--synapse/storage/schema/delta/16/unique_constraints.sql72
-rw-r--r--synapse/storage/schema/delta/16/users.sql56
-rw-r--r--synapse/storage/schema/delta/17/drop_indexes.sql18
-rw-r--r--synapse/storage/schema/delta/17/server_keys.sql24
-rw-r--r--synapse/storage/schema/delta/17/user_threepids.sql9
-rw-r--r--synapse/storage/schema/delta/18/server_keys_bigger_ints.sql32
-rw-r--r--synapse/storage/schema/delta/19/event_index.sql19
-rw-r--r--synapse/storage/schema/delta/20/dummy.sql1
-rw-r--r--synapse/storage/schema/delta/20/pushers.py88
-rw-r--r--synapse/storage/schema/delta/21/end_to_end_keys.sql34
-rw-r--r--synapse/storage/schema/delta/21/receipts.sql38
-rw-r--r--synapse/storage/schema/delta/22/receipts_index.sql22
-rw-r--r--synapse/storage/schema/delta/22/user_threepids_unique.sql19
-rw-r--r--synapse/storage/schema/delta/23/drop_state_index.sql16
-rw-r--r--synapse/storage/schema/delta/24/stats_reporting.sql18
-rw-r--r--synapse/storage/schema/delta/25/fts.py82
-rw-r--r--synapse/storage/schema/delta/25/guest_access.sql25
-rw-r--r--synapse/storage/schema/delta/25/history_visibility.sql25
-rw-r--r--synapse/storage/schema/delta/25/tags.sql38
-rw-r--r--synapse/storage/schema/delta/26/account_data.sql17
-rw-r--r--synapse/storage/schema/delta/27/account_data.sql36
-rw-r--r--synapse/storage/schema/delta/27/forgotten_memberships.sql26
-rw-r--r--synapse/storage/schema/delta/27/ts.py61
-rw-r--r--synapse/storage/schema/delta/28/event_push_actions.sql27
-rw-r--r--synapse/storage/schema/delta/28/events_room_stream.sql20
-rw-r--r--synapse/storage/schema/delta/28/public_roms_index.sql20
-rw-r--r--synapse/storage/schema/delta/28/receipts_user_id_index.sql22
-rw-r--r--synapse/storage/schema/delta/28/upgrade_times.sql21
-rw-r--r--synapse/storage/schema/delta/28/users_is_guest.sql22
-rw-r--r--synapse/storage/schema/delta/29/push_actions.sql35
-rw-r--r--synapse/storage/schema/delta/30/alias_creator.sql16
-rw-r--r--synapse/storage/schema/delta/30/as_users.py69
-rw-r--r--synapse/storage/schema/delta/30/deleted_pushers.sql25
-rw-r--r--synapse/storage/schema/delta/30/presence_stream.sql30
-rw-r--r--synapse/storage/schema/delta/30/public_rooms.sql23
-rw-r--r--synapse/storage/schema/delta/30/push_rule_stream.sql38
-rw-r--r--synapse/storage/schema/delta/30/state_stream.sql33
-rw-r--r--synapse/storage/schema/delta/30/threepid_guest_access_tokens.sql24
-rw-r--r--synapse/storage/schema/delta/31/invites.sql42
-rw-r--r--synapse/storage/schema/delta/31/local_media_repository_url_cache.sql27
-rw-r--r--synapse/storage/schema/delta/31/pushers.py87
-rw-r--r--synapse/storage/schema/delta/31/pushers_index.sql22
-rw-r--r--synapse/storage/schema/delta/31/search_update.py66
-rw-r--r--synapse/storage/schema/delta/32/openid.sql9
-rw-r--r--synapse/storage/schema/delta/32/pusher_throttle.sql23
-rw-r--r--synapse/storage/schema/delta/32/remove_indices.sql34
-rw-r--r--synapse/storage/schema/delta/32/reports.sql25
-rw-r--r--synapse/storage/schema/delta/33/access_tokens_device_index.sql17
-rw-r--r--synapse/storage/schema/delta/33/devices.sql21
-rw-r--r--synapse/storage/schema/delta/33/devices_for_e2e_keys.sql19
-rw-r--r--synapse/storage/schema/delta/33/devices_for_e2e_keys_clear_unknown_device.sql20
-rw-r--r--synapse/storage/schema/delta/33/event_fields.py61
-rw-r--r--synapse/storage/schema/delta/33/remote_media_ts.py30
-rw-r--r--synapse/storage/schema/delta/33/user_ips_index.sql17
-rw-r--r--synapse/storage/schema/delta/34/appservice_stream.sql23
-rw-r--r--synapse/storage/schema/delta/34/cache_stream.py46
-rw-r--r--synapse/storage/schema/delta/34/device_inbox.sql24
-rw-r--r--synapse/storage/schema/delta/34/push_display_name_rename.sql20
-rw-r--r--synapse/storage/schema/delta/34/received_txn_purge.py32
-rw-r--r--synapse/storage/schema/delta/35/00background_updates_add_col.sql (renamed from synapse/storage/schema/delta/32/events.sql)3
-rw-r--r--synapse/storage/schema/delta/35/add_state_index.sql20
-rw-r--r--synapse/storage/schema/delta/35/contains_url.sql17
-rw-r--r--synapse/storage/schema/delta/35/device_outbox.sql39
-rw-r--r--synapse/storage/schema/delta/35/device_stream_id.sql21
-rw-r--r--synapse/storage/schema/delta/35/event_push_actions_index.sql17
-rw-r--r--synapse/storage/schema/delta/35/public_room_list_change_stream.sql33
-rw-r--r--synapse/storage/schema/delta/35/state.sql22
-rw-r--r--synapse/storage/schema/delta/35/state_dedupe.sql17
-rw-r--r--synapse/storage/schema/delta/35/stream_order_to_extrem.sql37
-rw-r--r--synapse/storage/schema/delta/36/readd_public_rooms.sql26
-rw-r--r--synapse/storage/schema/delta/37/remove_auth_idx.py85
-rw-r--r--synapse/storage/schema/delta/37/user_threepids.sql52
-rw-r--r--synapse/storage/schema/delta/38/postgres_fts_gist.sql19
-rw-r--r--synapse/storage/schema/delta/39/appservice_room_list.sql29
-rw-r--r--synapse/storage/schema/delta/39/device_federation_stream_idx.sql16
-rw-r--r--synapse/storage/schema/delta/39/event_push_index.sql17
-rw-r--r--synapse/storage/schema/delta/39/federation_out_position.sql22
-rw-r--r--synapse/storage/schema/delta/39/membership_profile.sql20
-rw-r--r--synapse/storage/schema/delta/40/current_state_idx.sql17
-rw-r--r--synapse/storage/schema/delta/40/device_inbox.sql21
-rw-r--r--synapse/storage/schema/delta/40/device_list_streams.sql60
-rw-r--r--synapse/storage/schema/delta/40/event_push_summary.sql37
-rw-r--r--synapse/storage/schema/delta/40/pushers.sql39
-rw-r--r--synapse/storage/schema/delta/41/device_list_stream_idx.sql17
-rw-r--r--synapse/storage/schema/delta/41/device_outbound_index.sql16
-rw-r--r--synapse/storage/schema/delta/41/event_search_event_id_idx.sql17
-rw-r--r--synapse/storage/schema/delta/41/ratelimit.sql22
-rw-r--r--synapse/storage/schema/delta/42/current_state_delta.sql26
-rw-r--r--synapse/storage/schema/delta/42/device_list_last_id.sql33
-rw-r--r--synapse/storage/schema/delta/42/event_auth_state_only.sql17
-rw-r--r--synapse/storage/schema/delta/42/user_dir.py84
-rw-r--r--synapse/storage/schema/delta/43/blocked_rooms.sql21
-rw-r--r--synapse/storage/schema/delta/43/quarantine_media.sql17
-rw-r--r--synapse/storage/schema/delta/43/url_cache.sql16
-rw-r--r--synapse/storage/schema/delta/43/user_share.sql33
-rw-r--r--synapse/storage/schema/delta/44/expire_url_cache.sql41
-rw-r--r--synapse/storage/schema/delta/45/group_server.sql167
-rw-r--r--synapse/storage/schema/delta/45/profile_cache.sql28
-rw-r--r--synapse/storage/schema/delta/46/drop_refresh_tokens.sql17
-rw-r--r--synapse/storage/schema/delta/46/drop_unique_deleted_pushers.sql35
-rw-r--r--synapse/storage/schema/delta/46/group_server.sql32
-rw-r--r--synapse/storage/schema/delta/46/local_media_repository_url_idx.sql24
-rw-r--r--synapse/storage/schema/delta/46/user_dir_null_room_ids.sql35
-rw-r--r--synapse/storage/schema/delta/46/user_dir_typos.sql24
-rw-r--r--synapse/storage/schema/delta/47/last_access_media.sql16
-rw-r--r--synapse/storage/schema/delta/47/postgres_fts_gin.sql17
-rw-r--r--synapse/storage/schema/delta/47/push_actions_staging.sql28
-rw-r--r--synapse/storage/schema/delta/47/state_group_seq.py34
-rw-r--r--synapse/storage/schema/delta/48/add_user_consent.sql18
-rw-r--r--synapse/storage/schema/delta/48/add_user_ips_last_seen_index.sql17
-rw-r--r--synapse/storage/schema/delta/48/deactivated_users.sql25
-rw-r--r--synapse/storage/schema/delta/48/group_unique_indexes.py63
-rw-r--r--synapse/storage/schema/delta/48/groups_joinable.sql22
-rw-r--r--synapse/storage/schema/delta/49/add_user_consent_server_notice_sent.sql20
-rw-r--r--synapse/storage/schema/delta/49/add_user_daily_visits.sql21
-rw-r--r--synapse/storage/schema/delta/49/add_user_ips_last_seen_only_index.sql17
-rw-r--r--synapse/storage/schema/delta/50/add_creation_ts_users_index.sql19
-rw-r--r--synapse/storage/schema/delta/50/erasure_store.sql21
-rw-r--r--synapse/storage/schema/delta/50/make_event_content_nullable.py96
-rw-r--r--synapse/storage/schema/delta/51/e2e_room_keys.sql39
-rw-r--r--synapse/storage/schema/delta/51/monthly_active_users.sql27
-rw-r--r--synapse/storage/schema/delta/52/add_event_to_state_group_index.sql19
-rw-r--r--synapse/storage/schema/delta/52/device_list_streams_unique_idx.sql36
-rw-r--r--synapse/storage/schema/delta/52/e2e_room_keys.sql53
-rw-r--r--synapse/storage/schema/delta/53/add_user_type_to_users.sql19
-rw-r--r--synapse/storage/schema/delta/53/drop_sent_transactions.sql16
-rw-r--r--synapse/storage/schema/delta/53/event_format_version.sql16
-rw-r--r--synapse/storage/schema/delta/53/user_dir_populate.sql30
-rw-r--r--synapse/storage/schema/delta/53/user_ips_index.sql30
-rw-r--r--synapse/storage/schema/delta/53/user_share.sql44
-rw-r--r--synapse/storage/schema/delta/53/user_threepid_id.sql29
-rw-r--r--synapse/storage/schema/delta/53/users_in_public_rooms.sql28
-rw-r--r--synapse/storage/schema/delta/54/account_validity_with_renewal.sql30
-rw-r--r--synapse/storage/schema/delta/54/add_validity_to_server_keys.sql23
-rw-r--r--synapse/storage/schema/delta/54/delete_forward_extremities.sql23
-rw-r--r--synapse/storage/schema/delta/54/drop_legacy_tables.sql30
-rw-r--r--synapse/storage/schema/delta/54/drop_presence_list.sql16
-rw-r--r--synapse/storage/schema/delta/54/relations.sql27
-rw-r--r--synapse/storage/schema/delta/54/stats.sql80
-rw-r--r--synapse/storage/schema/delta/54/stats2.sql28
-rw-r--r--synapse/storage/schema/delta/55/access_token_expiry.sql18
-rw-r--r--synapse/storage/schema/delta/55/track_threepid_validations.sql31
-rw-r--r--synapse/storage/schema/delta/55/users_alter_deactivated.sql19
-rw-r--r--synapse/storage/schema/delta/56/add_spans_to_device_lists.sql20
-rw-r--r--synapse/storage/schema/delta/56/current_state_events_membership.sql22
-rw-r--r--synapse/storage/schema/delta/56/current_state_events_membership_mk2.sql24
-rw-r--r--synapse/storage/schema/delta/56/destinations_failure_ts.sql25
-rw-r--r--synapse/storage/schema/delta/56/destinations_retry_interval_type.sql.postgres18
-rw-r--r--synapse/storage/schema/delta/56/devices_last_seen.sql24
-rw-r--r--synapse/storage/schema/delta/56/drop_unused_event_tables.sql20
-rw-r--r--synapse/storage/schema/delta/56/fix_room_keys_index.sql18
-rw-r--r--synapse/storage/schema/delta/56/public_room_list_idx.sql16
-rw-r--r--synapse/storage/schema/delta/56/redaction_censor.sql17
-rw-r--r--synapse/storage/schema/delta/56/redaction_censor2.sql20
-rw-r--r--synapse/storage/schema/delta/56/redaction_censor3_fix_update.sql.postgres25
-rw-r--r--synapse/storage/schema/delta/56/room_membership_idx.sql18
-rw-r--r--synapse/storage/schema/delta/56/stats_separated.sql152
-rw-r--r--synapse/storage/schema/delta/56/unique_user_filter_index.py52
-rw-r--r--synapse/storage/schema/delta/56/user_external_ids.sql24
-rw-r--r--synapse/storage/schema/delta/56/users_in_public_rooms_idx.sql17
170 files changed, 2 insertions, 5109 deletions
diff --git a/synapse/storage/schema/delta/12/v12.sql b/synapse/storage/schema/delta/12/v12.sql
deleted file mode 100644
index 5964c5aaac..0000000000
--- a/synapse/storage/schema/delta/12/v12.sql
+++ /dev/null
@@ -1,63 +0,0 @@
-/* Copyright 2015, 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-CREATE TABLE IF NOT EXISTS rejections(
-    event_id TEXT NOT NULL,
-    reason TEXT NOT NULL,
-    last_check TEXT NOT NULL,
-    UNIQUE (event_id)
-);
-
--- Push notification endpoints that users have configured
-CREATE TABLE IF NOT EXISTS pushers (
-  id INTEGER PRIMARY KEY AUTOINCREMENT,
-  user_name TEXT NOT NULL,
-  profile_tag VARCHAR(32) NOT NULL,
-  kind VARCHAR(8) NOT NULL,
-  app_id VARCHAR(64) NOT NULL,
-  app_display_name VARCHAR(64) NOT NULL,
-  device_display_name VARCHAR(128) NOT NULL,
-  pushkey VARBINARY(512) NOT NULL,
-  ts BIGINT UNSIGNED NOT NULL,
-  lang VARCHAR(8),
-  data LONGBLOB,
-  last_token TEXT,
-  last_success BIGINT UNSIGNED,
-  failing_since BIGINT UNSIGNED,
-  UNIQUE (app_id, pushkey)
-);
-
-CREATE TABLE IF NOT EXISTS push_rules (
-  id INTEGER PRIMARY KEY AUTOINCREMENT,
-  user_name TEXT NOT NULL,
-  rule_id TEXT NOT NULL,
-  priority_class TINYINT NOT NULL,
-  priority INTEGER NOT NULL DEFAULT 0,
-  conditions TEXT NOT NULL,
-  actions TEXT NOT NULL,
-  UNIQUE(user_name, rule_id)
-);
-
-CREATE INDEX IF NOT EXISTS push_rules_user_name on push_rules (user_name);
-
-CREATE TABLE IF NOT EXISTS user_filters(
-  user_id TEXT,
-  filter_id BIGINT UNSIGNED,
-  filter_json LONGBLOB
-);
-
-CREATE INDEX IF NOT EXISTS user_filters_by_user_id_filter_id ON user_filters(
-    user_id, filter_id
-);
diff --git a/synapse/storage/schema/delta/13/v13.sql b/synapse/storage/schema/delta/13/v13.sql
deleted file mode 100644
index f8649e5d99..0000000000
--- a/synapse/storage/schema/delta/13/v13.sql
+++ /dev/null
@@ -1,19 +0,0 @@
-/* Copyright 2015, 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* We used to create a tables called application_services and
- * application_services_regex, but these are no longer used and are removed in
- * delta 54.
- */
diff --git a/synapse/storage/schema/delta/14/v14.sql b/synapse/storage/schema/delta/14/v14.sql
deleted file mode 100644
index a831920da6..0000000000
--- a/synapse/storage/schema/delta/14/v14.sql
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Copyright 2015, 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-CREATE TABLE IF NOT EXISTS push_rules_enable (
-  id INTEGER PRIMARY KEY AUTOINCREMENT,
-  user_name TEXT NOT NULL,
-  rule_id TEXT NOT NULL,
-  enabled TINYINT,
-  UNIQUE(user_name, rule_id)
-);
-
-CREATE INDEX IF NOT EXISTS push_rules_enable_user_name on push_rules_enable (user_name);
diff --git a/synapse/storage/schema/delta/15/appservice_txns.sql b/synapse/storage/schema/delta/15/appservice_txns.sql
deleted file mode 100644
index e4f5e76aec..0000000000
--- a/synapse/storage/schema/delta/15/appservice_txns.sql
+++ /dev/null
@@ -1,31 +0,0 @@
-/* Copyright 2015, 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-CREATE TABLE IF NOT EXISTS application_services_state(
-    as_id TEXT PRIMARY KEY,
-    state VARCHAR(5),
-    last_txn INTEGER
-);
-
-CREATE TABLE IF NOT EXISTS application_services_txns(
-    as_id TEXT NOT NULL,
-    txn_id INTEGER NOT NULL,
-    event_ids TEXT NOT NULL,
-    UNIQUE(as_id, txn_id)
-);
-
-CREATE INDEX IF NOT EXISTS application_services_txns_id ON application_services_txns (
-    as_id
-);
diff --git a/synapse/storage/schema/delta/15/presence_indices.sql b/synapse/storage/schema/delta/15/presence_indices.sql
deleted file mode 100644
index 6b8d0f1ca7..0000000000
--- a/synapse/storage/schema/delta/15/presence_indices.sql
+++ /dev/null
@@ -1,2 +0,0 @@
-
-CREATE INDEX IF NOT EXISTS presence_list_user_id ON presence_list (user_id);
diff --git a/synapse/storage/schema/delta/15/v15.sql b/synapse/storage/schema/delta/15/v15.sql
deleted file mode 100644
index 9523d2bcc3..0000000000
--- a/synapse/storage/schema/delta/15/v15.sql
+++ /dev/null
@@ -1,24 +0,0 @@
--- Drop, copy & recreate pushers table to change unique key
--- Also add access_token column at the same time
-CREATE TABLE IF NOT EXISTS pushers2 (
-  id BIGINT PRIMARY KEY,
-  user_name TEXT NOT NULL,
-  access_token BIGINT DEFAULT NULL,
-  profile_tag VARCHAR(32) NOT NULL,
-  kind VARCHAR(8) NOT NULL,
-  app_id VARCHAR(64) NOT NULL,
-  app_display_name VARCHAR(64) NOT NULL,
-  device_display_name VARCHAR(128) NOT NULL,
-  pushkey bytea NOT NULL,
-  ts BIGINT NOT NULL,
-  lang VARCHAR(8),
-  data bytea,
-  last_token TEXT,
-  last_success BIGINT,
-  failing_since BIGINT,
-  UNIQUE (app_id, pushkey)
-);
-INSERT INTO pushers2 (id, user_name, profile_tag, kind, app_id, app_display_name, device_display_name, pushkey, ts, lang, data, last_token, last_success, failing_since)
-  SELECT id, user_name, profile_tag, kind, app_id, app_display_name, device_display_name, pushkey, ts, lang, data, last_token, last_success, failing_since FROM pushers;
-DROP TABLE pushers;
-ALTER TABLE pushers2 RENAME TO pushers;
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);
-
diff --git a/synapse/storage/schema/delta/17/drop_indexes.sql b/synapse/storage/schema/delta/17/drop_indexes.sql
deleted file mode 100644
index 7c9a90e27f..0000000000
--- a/synapse/storage/schema/delta/17/drop_indexes.sql
+++ /dev/null
@@ -1,18 +0,0 @@
-/* Copyright 2015, 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-DROP INDEX IF EXISTS sent_transaction_dest;
-DROP INDEX IF EXISTS sent_transaction_sent;
-DROP INDEX IF EXISTS user_ips_user;
diff --git a/synapse/storage/schema/delta/17/server_keys.sql b/synapse/storage/schema/delta/17/server_keys.sql
deleted file mode 100644
index 70b247a06b..0000000000
--- a/synapse/storage/schema/delta/17/server_keys.sql
+++ /dev/null
@@ -1,24 +0,0 @@
-/* Copyright 2015, 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-CREATE TABLE IF NOT EXISTS server_keys_json (
-    server_name TEXT, -- Server name.
-    key_id TEXT, -- Requested key id.
-    from_server TEXT, -- Which server the keys were fetched from.
-    ts_added_ms INTEGER, -- When the keys were fetched
-    ts_valid_until_ms INTEGER, -- When this version of the keys exipires.
-    key_json bytea, -- JSON certificate for the remote server.
-    CONSTRAINT uniqueness UNIQUE (server_name, key_id, from_server)
-);
diff --git a/synapse/storage/schema/delta/17/user_threepids.sql b/synapse/storage/schema/delta/17/user_threepids.sql
deleted file mode 100644
index c17715ac80..0000000000
--- a/synapse/storage/schema/delta/17/user_threepids.sql
+++ /dev/null
@@ -1,9 +0,0 @@
-CREATE TABLE user_threepids (
-    user_id TEXT NOT NULL,
-    medium TEXT NOT NULL,
-    address TEXT NOT NULL,
-    validated_at BIGINT NOT NULL,
-    added_at BIGINT NOT NULL,
-    CONSTRAINT user_medium_address UNIQUE (user_id, medium, address)
-);
-CREATE INDEX user_threepids_user_id ON user_threepids(user_id);
diff --git a/synapse/storage/schema/delta/18/server_keys_bigger_ints.sql b/synapse/storage/schema/delta/18/server_keys_bigger_ints.sql
deleted file mode 100644
index 6e0871c92b..0000000000
--- a/synapse/storage/schema/delta/18/server_keys_bigger_ints.sql
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright 2015, 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-CREATE TABLE IF NOT EXISTS new_server_keys_json (
-    server_name TEXT NOT NULL, -- Server name.
-    key_id TEXT NOT NULL, -- Requested key id.
-    from_server TEXT NOT NULL, -- Which server the keys were fetched from.
-    ts_added_ms BIGINT NOT NULL, -- When the keys were fetched
-    ts_valid_until_ms BIGINT NOT NULL, -- When this version of the keys exipires.
-    key_json bytea NOT NULL, -- JSON certificate for the remote server.
-    CONSTRAINT server_keys_json_uniqueness UNIQUE (server_name, key_id, from_server)
-);
-
-INSERT INTO new_server_keys_json
-    SELECT server_name, key_id, from_server,ts_added_ms, ts_valid_until_ms, key_json FROM server_keys_json ;
-
-DROP TABLE server_keys_json;
-
-ALTER TABLE new_server_keys_json RENAME TO server_keys_json;
diff --git a/synapse/storage/schema/delta/19/event_index.sql b/synapse/storage/schema/delta/19/event_index.sql
deleted file mode 100644
index 18b97b4332..0000000000
--- a/synapse/storage/schema/delta/19/event_index.sql
+++ /dev/null
@@ -1,19 +0,0 @@
-/* Copyright 2015, 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-CREATE INDEX events_order_topo_stream_room ON events(
-    topological_ordering, stream_ordering, room_id
-);
diff --git a/synapse/storage/schema/delta/20/dummy.sql b/synapse/storage/schema/delta/20/dummy.sql
deleted file mode 100644
index e0ac49d1ec..0000000000
--- a/synapse/storage/schema/delta/20/dummy.sql
+++ /dev/null
@@ -1 +0,0 @@
-SELECT 1;
diff --git a/synapse/storage/schema/delta/20/pushers.py b/synapse/storage/schema/delta/20/pushers.py
deleted file mode 100644
index 3edfcfd783..0000000000
--- a/synapse/storage/schema/delta/20/pushers.py
+++ /dev/null
@@ -1,88 +0,0 @@
-# Copyright 2015, 2016 OpenMarket Ltd
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
-"""
-Main purpose of this upgrade is to change the unique key on the
-pushers table again (it was missed when the v16 full schema was
-made) but this also changes the pushkey and data columns to text.
-When selecting a bytea column into a text column, postgres inserts
-the hex encoded data, and there's no portable way of getting the
-UTF-8 bytes, so we have to do it in Python.
-"""
-
-import logging
-
-logger = logging.getLogger(__name__)
-
-
-def run_create(cur, database_engine, *args, **kwargs):
-    logger.info("Porting pushers table...")
-    cur.execute(
-        """
-        CREATE TABLE IF NOT EXISTS pushers2 (
-          id BIGINT PRIMARY KEY,
-          user_name TEXT NOT NULL,
-          access_token BIGINT DEFAULT NULL,
-          profile_tag VARCHAR(32) NOT NULL,
-          kind VARCHAR(8) NOT NULL,
-          app_id VARCHAR(64) NOT NULL,
-          app_display_name VARCHAR(64) NOT NULL,
-          device_display_name VARCHAR(128) NOT NULL,
-          pushkey TEXT NOT NULL,
-          ts BIGINT NOT NULL,
-          lang VARCHAR(8),
-          data TEXT,
-          last_token TEXT,
-          last_success BIGINT,
-          failing_since BIGINT,
-          UNIQUE (app_id, pushkey, user_name)
-        )
-    """
-    )
-    cur.execute(
-        """SELECT
-        id, user_name, access_token, profile_tag, kind,
-        app_id, app_display_name, device_display_name,
-        pushkey, ts, lang, data, last_token, last_success,
-        failing_since
-        FROM pushers
-    """
-    )
-    count = 0
-    for row in cur.fetchall():
-        row = list(row)
-        row[8] = bytes(row[8]).decode("utf-8")
-        row[11] = bytes(row[11]).decode("utf-8")
-        cur.execute(
-            database_engine.convert_param_style(
-                """
-            INSERT into pushers2 (
-            id, user_name, access_token, profile_tag, kind,
-            app_id, app_display_name, device_display_name,
-            pushkey, ts, lang, data, last_token, last_success,
-            failing_since
-            ) values (%s)"""
-                % (",".join(["?" for _ in range(len(row))]))
-            ),
-            row,
-        )
-        count += 1
-    cur.execute("DROP TABLE pushers")
-    cur.execute("ALTER TABLE pushers2 RENAME TO pushers")
-    logger.info("Moved %d pushers to new table", count)
-
-
-def run_upgrade(*args, **kwargs):
-    pass
diff --git a/synapse/storage/schema/delta/21/end_to_end_keys.sql b/synapse/storage/schema/delta/21/end_to_end_keys.sql
deleted file mode 100644
index 4c2fb20b77..0000000000
--- a/synapse/storage/schema/delta/21/end_to_end_keys.sql
+++ /dev/null
@@ -1,34 +0,0 @@
-/* Copyright 2015, 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-CREATE TABLE IF NOT EXISTS e2e_device_keys_json (
-    user_id TEXT NOT NULL, -- The user these keys are for.
-    device_id TEXT NOT NULL, -- Which of the user's devices these keys are for.
-    ts_added_ms BIGINT NOT NULL, -- When the keys were uploaded.
-    key_json TEXT NOT NULL, -- The keys for the device as a JSON blob.
-    CONSTRAINT e2e_device_keys_json_uniqueness UNIQUE (user_id, device_id)
-);
-
-
-CREATE TABLE IF NOT EXISTS e2e_one_time_keys_json (
-    user_id TEXT NOT NULL, -- The user this one-time key is for.
-    device_id TEXT NOT NULL, -- The device this one-time key is for.
-    algorithm TEXT NOT NULL, -- Which algorithm this one-time key is for.
-    key_id TEXT NOT NULL, -- An id for suppressing duplicate uploads.
-    ts_added_ms BIGINT NOT NULL, -- When this key was uploaded.
-    key_json TEXT NOT NULL, -- The key as a JSON blob.
-    CONSTRAINT e2e_one_time_keys_json_uniqueness UNIQUE (user_id, device_id, algorithm, key_id)
-);
diff --git a/synapse/storage/schema/delta/21/receipts.sql b/synapse/storage/schema/delta/21/receipts.sql
deleted file mode 100644
index d070845477..0000000000
--- a/synapse/storage/schema/delta/21/receipts.sql
+++ /dev/null
@@ -1,38 +0,0 @@
-/* Copyright 2015, 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-CREATE TABLE IF NOT EXISTS receipts_graph(
-    room_id TEXT NOT NULL,
-    receipt_type TEXT NOT NULL,
-    user_id TEXT NOT NULL,
-    event_ids TEXT NOT NULL,
-    data TEXT NOT NULL,
-    CONSTRAINT receipts_graph_uniqueness UNIQUE (room_id, receipt_type, user_id)
-);
-
-CREATE TABLE IF NOT EXISTS receipts_linearized (
-    stream_id BIGINT NOT NULL,
-    room_id TEXT NOT NULL,
-    receipt_type TEXT NOT NULL,
-    user_id TEXT NOT NULL,
-    event_id TEXT NOT NULL,
-    data TEXT NOT NULL,
-    CONSTRAINT receipts_linearized_uniqueness UNIQUE (room_id, receipt_type, user_id)
-);
-
-CREATE INDEX receipts_linearized_id ON receipts_linearized(
-  stream_id
-);
diff --git a/synapse/storage/schema/delta/22/receipts_index.sql b/synapse/storage/schema/delta/22/receipts_index.sql
deleted file mode 100644
index bfc0b3bcaa..0000000000
--- a/synapse/storage/schema/delta/22/receipts_index.sql
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Copyright 2015, 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/** Using CREATE INDEX directly is deprecated in favour of using background
- * update see synapse/storage/schema/delta/33/access_tokens_device_index.sql
- * and synapse/storage/registration.py for an example using
- * "access_tokens_device_index" **/
-CREATE INDEX receipts_linearized_room_stream ON receipts_linearized(
-    room_id, stream_id
-);
diff --git a/synapse/storage/schema/delta/22/user_threepids_unique.sql b/synapse/storage/schema/delta/22/user_threepids_unique.sql
deleted file mode 100644
index 87edfa454c..0000000000
--- a/synapse/storage/schema/delta/22/user_threepids_unique.sql
+++ /dev/null
@@ -1,19 +0,0 @@
-CREATE TABLE IF NOT EXISTS user_threepids2 (
-    user_id TEXT NOT NULL,
-    medium TEXT NOT NULL,
-    address TEXT NOT NULL,
-    validated_at BIGINT NOT NULL,
-    added_at BIGINT NOT NULL,
-    CONSTRAINT medium_address UNIQUE (medium, address)
-);
-
-INSERT INTO user_threepids2
-	SELECT * FROM user_threepids WHERE added_at IN (
-		SELECT max(added_at) FROM user_threepids GROUP BY medium, address
-	)
-;
-
-DROP TABLE user_threepids;
-ALTER TABLE user_threepids2 RENAME TO user_threepids;
-
-CREATE INDEX user_threepids_user_id ON user_threepids(user_id);
diff --git a/synapse/storage/schema/delta/23/drop_state_index.sql b/synapse/storage/schema/delta/23/drop_state_index.sql
deleted file mode 100644
index ae09fa0065..0000000000
--- a/synapse/storage/schema/delta/23/drop_state_index.sql
+++ /dev/null
@@ -1,16 +0,0 @@
-/* Copyright 2015, 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-DROP INDEX IF EXISTS state_groups_state_tuple;
diff --git a/synapse/storage/schema/delta/24/stats_reporting.sql b/synapse/storage/schema/delta/24/stats_reporting.sql
deleted file mode 100644
index acea7483bd..0000000000
--- a/synapse/storage/schema/delta/24/stats_reporting.sql
+++ /dev/null
@@ -1,18 +0,0 @@
-/* Copyright 2019 New Vector Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
- /* We used to create a table called stats_reporting, but this is no longer
- * used and is removed in delta 54.
- */
\ No newline at end of file
diff --git a/synapse/storage/schema/delta/25/fts.py b/synapse/storage/schema/delta/25/fts.py
deleted file mode 100644
index 4b2ffd35fd..0000000000
--- a/synapse/storage/schema/delta/25/fts.py
+++ /dev/null
@@ -1,82 +0,0 @@
-# Copyright 2015, 2016 OpenMarket Ltd
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import logging
-
-import simplejson
-
-from synapse.storage.engines import PostgresEngine, Sqlite3Engine
-from synapse.storage.prepare_database import get_statements
-
-logger = logging.getLogger(__name__)
-
-
-POSTGRES_TABLE = """
-CREATE TABLE IF NOT EXISTS event_search (
-    event_id TEXT,
-    room_id TEXT,
-    sender TEXT,
-    key TEXT,
-    vector tsvector
-);
-
-CREATE INDEX event_search_fts_idx ON event_search USING gin(vector);
-CREATE INDEX event_search_ev_idx ON event_search(event_id);
-CREATE INDEX event_search_ev_ridx ON event_search(room_id);
-"""
-
-
-SQLITE_TABLE = (
-    "CREATE VIRTUAL TABLE event_search"
-    " USING fts4 ( event_id, room_id, sender, key, value )"
-)
-
-
-def run_create(cur, database_engine, *args, **kwargs):
-    if isinstance(database_engine, PostgresEngine):
-        for statement in get_statements(POSTGRES_TABLE.splitlines()):
-            cur.execute(statement)
-    elif isinstance(database_engine, Sqlite3Engine):
-        cur.execute(SQLITE_TABLE)
-    else:
-        raise Exception("Unrecognized database engine")
-
-    cur.execute("SELECT MIN(stream_ordering) FROM events")
-    rows = cur.fetchall()
-    min_stream_id = rows[0][0]
-
-    cur.execute("SELECT MAX(stream_ordering) FROM events")
-    rows = cur.fetchall()
-    max_stream_id = rows[0][0]
-
-    if min_stream_id is not None and max_stream_id is not None:
-        progress = {
-            "target_min_stream_id_inclusive": min_stream_id,
-            "max_stream_id_exclusive": max_stream_id + 1,
-            "rows_inserted": 0,
-        }
-        progress_json = simplejson.dumps(progress)
-
-        sql = (
-            "INSERT into background_updates (update_name, progress_json)"
-            " VALUES (?, ?)"
-        )
-
-        sql = database_engine.convert_param_style(sql)
-
-        cur.execute(sql, ("event_search", progress_json))
-
-
-def run_upgrade(*args, **kwargs):
-    pass
diff --git a/synapse/storage/schema/delta/25/guest_access.sql b/synapse/storage/schema/delta/25/guest_access.sql
deleted file mode 100644
index 1ea389b471..0000000000
--- a/synapse/storage/schema/delta/25/guest_access.sql
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Copyright 2015, 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * This is a manual index of guest_access content of state events,
- * so that we can join on them in SELECT statements.
- */
-CREATE TABLE IF NOT EXISTS guest_access(
-    event_id TEXT NOT NULL,
-    room_id TEXT NOT NULL,
-    guest_access TEXT NOT NULL,
-    UNIQUE (event_id)
-);
diff --git a/synapse/storage/schema/delta/25/history_visibility.sql b/synapse/storage/schema/delta/25/history_visibility.sql
deleted file mode 100644
index f468fc1897..0000000000
--- a/synapse/storage/schema/delta/25/history_visibility.sql
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Copyright 2015, 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * This is a manual index of history_visibility content of state events,
- * so that we can join on them in SELECT statements.
- */
-CREATE TABLE IF NOT EXISTS history_visibility(
-    event_id TEXT NOT NULL,
-    room_id TEXT NOT NULL,
-    history_visibility TEXT NOT NULL,
-    UNIQUE (event_id)
-);
diff --git a/synapse/storage/schema/delta/25/tags.sql b/synapse/storage/schema/delta/25/tags.sql
deleted file mode 100644
index 7a32ce68e4..0000000000
--- a/synapse/storage/schema/delta/25/tags.sql
+++ /dev/null
@@ -1,38 +0,0 @@
-/* Copyright 2015, 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-CREATE TABLE IF NOT EXISTS room_tags(
-    user_id TEXT NOT NULL,
-    room_id TEXT NOT NULL,
-    tag     TEXT NOT NULL,  -- The name of the tag.
-    content TEXT NOT NULL,  -- The JSON content of the tag.
-    CONSTRAINT room_tag_uniqueness UNIQUE (user_id, room_id, tag)
-);
-
-CREATE TABLE IF NOT EXISTS room_tags_revisions (
-    user_id TEXT NOT NULL,
-    room_id TEXT NOT NULL,
-    stream_id BIGINT NOT NULL, -- The current version of the room tags.
-    CONSTRAINT room_tag_revisions_uniqueness UNIQUE (user_id, room_id)
-);
-
-CREATE TABLE IF NOT EXISTS private_user_data_max_stream_id(
-    Lock CHAR(1) NOT NULL DEFAULT 'X' UNIQUE,  -- Makes sure this table only has one row.
-    stream_id  BIGINT NOT NULL,
-    CHECK (Lock='X')
-);
-
-INSERT INTO private_user_data_max_stream_id (stream_id) VALUES (0);
diff --git a/synapse/storage/schema/delta/26/account_data.sql b/synapse/storage/schema/delta/26/account_data.sql
deleted file mode 100644
index e395de2b5e..0000000000
--- a/synapse/storage/schema/delta/26/account_data.sql
+++ /dev/null
@@ -1,17 +0,0 @@
-/* Copyright 2015, 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-ALTER TABLE private_user_data_max_stream_id RENAME TO account_data_max_stream_id;
diff --git a/synapse/storage/schema/delta/27/account_data.sql b/synapse/storage/schema/delta/27/account_data.sql
deleted file mode 100644
index bf0558b5b3..0000000000
--- a/synapse/storage/schema/delta/27/account_data.sql
+++ /dev/null
@@ -1,36 +0,0 @@
-/* Copyright 2015, 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-CREATE TABLE IF NOT EXISTS account_data(
-    user_id TEXT NOT NULL,
-    account_data_type TEXT NOT NULL, -- The type of the account_data.
-    stream_id BIGINT NOT NULL, -- The version of the account_data.
-    content TEXT NOT NULL,  -- The JSON content of the account_data
-    CONSTRAINT account_data_uniqueness UNIQUE (user_id, account_data_type)
-);
-
-
-CREATE TABLE IF NOT EXISTS room_account_data(
-    user_id TEXT NOT NULL,
-    room_id TEXT NOT NULL,
-    account_data_type TEXT NOT NULL, -- The type of the account_data.
-    stream_id BIGINT NOT NULL, -- The version of the account_data.
-    content TEXT NOT NULL,  -- The JSON content of the account_data
-    CONSTRAINT room_account_data_uniqueness UNIQUE (user_id, room_id, account_data_type)
-);
-
-
-CREATE INDEX account_data_stream_id on account_data(user_id, stream_id);
-CREATE INDEX room_account_data_stream_id on room_account_data(user_id, stream_id);
diff --git a/synapse/storage/schema/delta/27/forgotten_memberships.sql b/synapse/storage/schema/delta/27/forgotten_memberships.sql
deleted file mode 100644
index e2094f37fe..0000000000
--- a/synapse/storage/schema/delta/27/forgotten_memberships.sql
+++ /dev/null
@@ -1,26 +0,0 @@
-/* Copyright 2015, 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * Keeps track of what rooms users have left and don't want to be able to
- * access again.
- *
- * If all users on this server have left a room, we can delete the room
- * entirely.
- *
- * This column should always contain either 0 or 1.
- */
-
- ALTER TABLE room_memberships ADD COLUMN forgotten INTEGER DEFAULT 0;
diff --git a/synapse/storage/schema/delta/27/ts.py b/synapse/storage/schema/delta/27/ts.py
deleted file mode 100644
index 414f9f5aa0..0000000000
--- a/synapse/storage/schema/delta/27/ts.py
+++ /dev/null
@@ -1,61 +0,0 @@
-# Copyright 2015, 2016 OpenMarket Ltd
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import logging
-
-import simplejson
-
-from synapse.storage.prepare_database import get_statements
-
-logger = logging.getLogger(__name__)
-
-
-ALTER_TABLE = (
-    "ALTER TABLE events ADD COLUMN origin_server_ts BIGINT;"
-    "CREATE INDEX events_ts ON events(origin_server_ts, stream_ordering);"
-)
-
-
-def run_create(cur, database_engine, *args, **kwargs):
-    for statement in get_statements(ALTER_TABLE.splitlines()):
-        cur.execute(statement)
-
-    cur.execute("SELECT MIN(stream_ordering) FROM events")
-    rows = cur.fetchall()
-    min_stream_id = rows[0][0]
-
-    cur.execute("SELECT MAX(stream_ordering) FROM events")
-    rows = cur.fetchall()
-    max_stream_id = rows[0][0]
-
-    if min_stream_id is not None and max_stream_id is not None:
-        progress = {
-            "target_min_stream_id_inclusive": min_stream_id,
-            "max_stream_id_exclusive": max_stream_id + 1,
-            "rows_inserted": 0,
-        }
-        progress_json = simplejson.dumps(progress)
-
-        sql = (
-            "INSERT into background_updates (update_name, progress_json)"
-            " VALUES (?, ?)"
-        )
-
-        sql = database_engine.convert_param_style(sql)
-
-        cur.execute(sql, ("event_origin_server_ts", progress_json))
-
-
-def run_upgrade(*args, **kwargs):
-    pass
diff --git a/synapse/storage/schema/delta/28/event_push_actions.sql b/synapse/storage/schema/delta/28/event_push_actions.sql
deleted file mode 100644
index 4d519849df..0000000000
--- a/synapse/storage/schema/delta/28/event_push_actions.sql
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Copyright 2015 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-CREATE TABLE IF NOT EXISTS event_push_actions(
-    room_id TEXT NOT NULL,
-    event_id TEXT NOT NULL,
-    user_id TEXT NOT NULL,
-    profile_tag VARCHAR(32),
-    actions TEXT NOT NULL,
-    CONSTRAINT event_id_user_id_profile_tag_uniqueness UNIQUE (room_id, event_id, user_id, profile_tag)
-);
-
-
-CREATE INDEX event_push_actions_room_id_event_id_user_id_profile_tag on event_push_actions(room_id, event_id, user_id, profile_tag);
-CREATE INDEX event_push_actions_room_id_user_id on event_push_actions(room_id, user_id);
diff --git a/synapse/storage/schema/delta/28/events_room_stream.sql b/synapse/storage/schema/delta/28/events_room_stream.sql
deleted file mode 100644
index 36609475f1..0000000000
--- a/synapse/storage/schema/delta/28/events_room_stream.sql
+++ /dev/null
@@ -1,20 +0,0 @@
-/* Copyright 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-/** Using CREATE INDEX directly is deprecated in favour of using background
- * update see synapse/storage/schema/delta/33/access_tokens_device_index.sql
- * and synapse/storage/registration.py for an example using
- * "access_tokens_device_index" **/
-CREATE INDEX events_room_stream on events(room_id, stream_ordering);
diff --git a/synapse/storage/schema/delta/28/public_roms_index.sql b/synapse/storage/schema/delta/28/public_roms_index.sql
deleted file mode 100644
index 6c1fd68c5b..0000000000
--- a/synapse/storage/schema/delta/28/public_roms_index.sql
+++ /dev/null
@@ -1,20 +0,0 @@
-/* Copyright 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-/** Using CREATE INDEX directly is deprecated in favour of using background
- * update see synapse/storage/schema/delta/33/access_tokens_device_index.sql
- * and synapse/storage/registration.py for an example using
- * "access_tokens_device_index" **/
-CREATE INDEX public_room_index on rooms(is_public);
diff --git a/synapse/storage/schema/delta/28/receipts_user_id_index.sql b/synapse/storage/schema/delta/28/receipts_user_id_index.sql
deleted file mode 100644
index cb84c69baa..0000000000
--- a/synapse/storage/schema/delta/28/receipts_user_id_index.sql
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Copyright 2015, 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/** Using CREATE INDEX directly is deprecated in favour of using background
- * update see synapse/storage/schema/delta/33/access_tokens_device_index.sql
- * and synapse/storage/registration.py for an example using
- * "access_tokens_device_index" **/
-CREATE INDEX receipts_linearized_user ON receipts_linearized(
-    user_id
-);
diff --git a/synapse/storage/schema/delta/28/upgrade_times.sql b/synapse/storage/schema/delta/28/upgrade_times.sql
deleted file mode 100644
index 3e4a9ab455..0000000000
--- a/synapse/storage/schema/delta/28/upgrade_times.sql
+++ /dev/null
@@ -1,21 +0,0 @@
-/* Copyright 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * Stores the timestamp when a user upgraded from a guest to a full user, if
- * that happened.
- */
-
-ALTER TABLE users ADD COLUMN upgrade_ts BIGINT;
diff --git a/synapse/storage/schema/delta/28/users_is_guest.sql b/synapse/storage/schema/delta/28/users_is_guest.sql
deleted file mode 100644
index 21d2b420bf..0000000000
--- a/synapse/storage/schema/delta/28/users_is_guest.sql
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Copyright 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-ALTER TABLE users ADD is_guest SMALLINT DEFAULT 0 NOT NULL;
-/*
- * NB: any guest users created between 27 and 28 will be incorrectly
- * marked as not guests: we don't bother to fill these in correctly
- * because guest access is not really complete in 27 anyway so it's
- * very unlikley there will be any guest users created.
- */
diff --git a/synapse/storage/schema/delta/29/push_actions.sql b/synapse/storage/schema/delta/29/push_actions.sql
deleted file mode 100644
index 84b21cf813..0000000000
--- a/synapse/storage/schema/delta/29/push_actions.sql
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Copyright 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-ALTER TABLE event_push_actions ADD COLUMN topological_ordering BIGINT;
-ALTER TABLE event_push_actions ADD COLUMN stream_ordering BIGINT;
-ALTER TABLE event_push_actions ADD COLUMN notif SMALLINT;
-ALTER TABLE event_push_actions ADD COLUMN highlight SMALLINT;
-
-UPDATE event_push_actions SET stream_ordering = (
-    SELECT stream_ordering FROM events WHERE event_id = event_push_actions.event_id
-), topological_ordering = (
-    SELECT topological_ordering FROM events WHERE event_id = event_push_actions.event_id
-);
-
-UPDATE event_push_actions SET notif = 1, highlight = 0;
-
-/** Using CREATE INDEX directly is deprecated in favour of using background
- * update see synapse/storage/schema/delta/33/access_tokens_device_index.sql
- * and synapse/storage/registration.py for an example using
- * "access_tokens_device_index" **/
-CREATE INDEX event_push_actions_rm_tokens on event_push_actions(
-    user_id, room_id, topological_ordering, stream_ordering
-);
diff --git a/synapse/storage/schema/delta/30/alias_creator.sql b/synapse/storage/schema/delta/30/alias_creator.sql
deleted file mode 100644
index c9d0dde638..0000000000
--- a/synapse/storage/schema/delta/30/alias_creator.sql
+++ /dev/null
@@ -1,16 +0,0 @@
-/* Copyright 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-ALTER TABLE room_aliases ADD COLUMN creator TEXT;
diff --git a/synapse/storage/schema/delta/30/as_users.py b/synapse/storage/schema/delta/30/as_users.py
deleted file mode 100644
index 9b95411fb6..0000000000
--- a/synapse/storage/schema/delta/30/as_users.py
+++ /dev/null
@@ -1,69 +0,0 @@
-# Copyright 2016 OpenMarket Ltd
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-import logging
-
-from six.moves import range
-
-from synapse.config.appservice import load_appservices
-
-logger = logging.getLogger(__name__)
-
-
-def run_create(cur, database_engine, *args, **kwargs):
-    # NULL indicates user was not registered by an appservice.
-    try:
-        cur.execute("ALTER TABLE users ADD COLUMN appservice_id TEXT")
-    except Exception:
-        # Maybe we already added the column? Hope so...
-        pass
-
-
-def run_upgrade(cur, database_engine, config, *args, **kwargs):
-    cur.execute("SELECT name FROM users")
-    rows = cur.fetchall()
-
-    config_files = []
-    try:
-        config_files = config.app_service_config_files
-    except AttributeError:
-        logger.warning("Could not get app_service_config_files from config")
-        pass
-
-    appservices = load_appservices(config.server_name, config_files)
-
-    owned = {}
-
-    for row in rows:
-        user_id = row[0]
-        for appservice in appservices:
-            if appservice.is_exclusive_user(user_id):
-                if user_id in owned.keys():
-                    logger.error(
-                        "user_id %s was owned by more than one application"
-                        " service (IDs %s and %s); assigning arbitrarily to %s"
-                        % (user_id, owned[user_id], appservice.id, owned[user_id])
-                    )
-                owned.setdefault(appservice.id, []).append(user_id)
-
-    for as_id, user_ids in owned.items():
-        n = 100
-        user_chunks = (user_ids[i : i + 100] for i in range(0, len(user_ids), n))
-        for chunk in user_chunks:
-            cur.execute(
-                database_engine.convert_param_style(
-                    "UPDATE users SET appservice_id = ? WHERE name IN (%s)"
-                    % (",".join("?" for _ in chunk),)
-                ),
-                [as_id] + chunk,
-            )
diff --git a/synapse/storage/schema/delta/30/deleted_pushers.sql b/synapse/storage/schema/delta/30/deleted_pushers.sql
deleted file mode 100644
index 712c454aa1..0000000000
--- a/synapse/storage/schema/delta/30/deleted_pushers.sql
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Copyright 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-CREATE TABLE IF NOT EXISTS deleted_pushers(
-    stream_id BIGINT NOT NULL,
-    app_id TEXT NOT NULL,
-    pushkey TEXT NOT NULL,
-    user_id TEXT NOT NULL,
-    /* We only track the most recent delete for each app_id, pushkey and user_id. */
-    UNIQUE (app_id, pushkey, user_id)
-);
-
-CREATE INDEX deleted_pushers_stream_id ON deleted_pushers (stream_id);
diff --git a/synapse/storage/schema/delta/30/presence_stream.sql b/synapse/storage/schema/delta/30/presence_stream.sql
deleted file mode 100644
index 606bbb037d..0000000000
--- a/synapse/storage/schema/delta/30/presence_stream.sql
+++ /dev/null
@@ -1,30 +0,0 @@
-/* Copyright 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
- CREATE TABLE presence_stream(
-     stream_id BIGINT,
-     user_id TEXT,
-     state TEXT,
-     last_active_ts BIGINT,
-     last_federation_update_ts BIGINT,
-     last_user_sync_ts BIGINT,
-     status_msg TEXT,
-     currently_active BOOLEAN
- );
-
- CREATE INDEX presence_stream_id ON presence_stream(stream_id, user_id);
- CREATE INDEX presence_stream_user_id ON presence_stream(user_id);
- CREATE INDEX presence_stream_state ON presence_stream(state);
diff --git a/synapse/storage/schema/delta/30/public_rooms.sql b/synapse/storage/schema/delta/30/public_rooms.sql
deleted file mode 100644
index f09db4faa6..0000000000
--- a/synapse/storage/schema/delta/30/public_rooms.sql
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Copyright 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-/* This release removes the restriction that published rooms must have an alias,
- * so we go back and ensure the only 'public' rooms are ones with an alias.
- * We use (1 = 0) and (1 = 1) so that it works in both postgres and sqlite
- */
-UPDATE rooms SET is_public = (1 = 0) WHERE is_public = (1 = 1) AND room_id not in (
-    SELECT room_id FROM room_aliases
-);
diff --git a/synapse/storage/schema/delta/30/push_rule_stream.sql b/synapse/storage/schema/delta/30/push_rule_stream.sql
deleted file mode 100644
index 735aa8d5f6..0000000000
--- a/synapse/storage/schema/delta/30/push_rule_stream.sql
+++ /dev/null
@@ -1,38 +0,0 @@
-/* Copyright 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-
-CREATE TABLE push_rules_stream(
-    stream_id BIGINT NOT NULL,
-    event_stream_ordering BIGINT NOT NULL,
-    user_id TEXT NOT NULL,
-    rule_id TEXT NOT NULL,
-    op TEXT NOT NULL, -- One of "ENABLE", "DISABLE", "ACTIONS", "ADD", "DELETE"
-    priority_class SMALLINT,
-    priority INTEGER,
-    conditions TEXT,
-    actions TEXT
-);
-
--- The extra data for each operation is:
--- * ENABLE, DISABLE, DELETE: []
--- * ACTIONS: ["actions"]
--- * ADD: ["priority_class", "priority", "actions", "conditions"]
-
--- Index for replication queries.
-CREATE INDEX push_rules_stream_id ON push_rules_stream(stream_id);
--- Index for /sync queries.
-CREATE INDEX push_rules_stream_user_stream_id on push_rules_stream(user_id, stream_id);
diff --git a/synapse/storage/schema/delta/30/state_stream.sql b/synapse/storage/schema/delta/30/state_stream.sql
deleted file mode 100644
index e85699e82e..0000000000
--- a/synapse/storage/schema/delta/30/state_stream.sql
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Copyright 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-/* We used to create a table called current_state_resets, but this is no
- * longer used and is removed in delta 54.
- */
-
-/* The outlier events that have aquired a state group typically through
- * backfill. This is tracked separately to the events table, as assigning a
- * state group change the position of the existing event in the stream
- * ordering.
- * However since a stream_ordering is assigned in persist_event for the
- * (event, state) pair, we can use that stream_ordering to identify when
- * the new state was assigned for the event.
- */
-CREATE TABLE IF NOT EXISTS ex_outlier_stream(
-    event_stream_ordering BIGINT PRIMARY KEY NOT NULL,
-    event_id TEXT NOT NULL,
-    state_group BIGINT NOT NULL
-);
diff --git a/synapse/storage/schema/delta/30/threepid_guest_access_tokens.sql b/synapse/storage/schema/delta/30/threepid_guest_access_tokens.sql
deleted file mode 100644
index 0dd2f1360c..0000000000
--- a/synapse/storage/schema/delta/30/threepid_guest_access_tokens.sql
+++ /dev/null
@@ -1,24 +0,0 @@
-/* Copyright 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
--- Stores guest account access tokens generated for unbound 3pids.
-CREATE TABLE threepid_guest_access_tokens(
-    medium TEXT, -- The medium of the 3pid. Must be "email".
-    address TEXT, -- The 3pid address.
-    guest_access_token TEXT, -- The access token for a guest user for this 3pid.
-    first_inviter TEXT -- User ID of the first user to invite this 3pid to a room.
-);
-
-CREATE UNIQUE INDEX threepid_guest_access_tokens_index ON threepid_guest_access_tokens(medium, address);
diff --git a/synapse/storage/schema/delta/31/invites.sql b/synapse/storage/schema/delta/31/invites.sql
deleted file mode 100644
index 2c57846d5a..0000000000
--- a/synapse/storage/schema/delta/31/invites.sql
+++ /dev/null
@@ -1,42 +0,0 @@
-/* Copyright 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-CREATE TABLE local_invites(
-    stream_id BIGINT NOT NULL,
-    inviter TEXT NOT NULL,
-    invitee TEXT NOT NULL,
-    event_id TEXT NOT NULL,
-    room_id TEXT NOT NULL,
-    locally_rejected TEXT,
-    replaced_by TEXT
-);
-
--- Insert all invites for local users into new `invites` table
-INSERT INTO local_invites SELECT
-        stream_ordering as stream_id,
-        sender as inviter,
-        state_key as invitee,
-        event_id,
-        room_id,
-        NULL as locally_rejected,
-        NULL as replaced_by
-    FROM events
-    NATURAL JOIN current_state_events
-    NATURAL JOIN room_memberships
-    WHERE membership = 'invite'  AND state_key IN (SELECT name FROM users);
-
-CREATE INDEX local_invites_id ON local_invites(stream_id);
-CREATE INDEX local_invites_for_user_idx ON local_invites(invitee, locally_rejected, replaced_by, room_id);
diff --git a/synapse/storage/schema/delta/31/local_media_repository_url_cache.sql b/synapse/storage/schema/delta/31/local_media_repository_url_cache.sql
deleted file mode 100644
index 9efb4280eb..0000000000
--- a/synapse/storage/schema/delta/31/local_media_repository_url_cache.sql
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Copyright 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-CREATE TABLE local_media_repository_url_cache(
-    url TEXT,              -- the URL being cached
-    response_code INTEGER, -- the HTTP response code of this download attempt
-    etag TEXT,             -- the etag header of this response
-    expires INTEGER,       -- the number of ms this response was valid for
-    og TEXT,               -- cache of the OG metadata of this URL as JSON
-    media_id TEXT,         -- the media_id, if any, of the URL's content in the repo
-    download_ts BIGINT     -- the timestamp of this download attempt
-);
-
-CREATE INDEX local_media_repository_url_cache_by_url_download_ts
-    ON local_media_repository_url_cache(url, download_ts);
diff --git a/synapse/storage/schema/delta/31/pushers.py b/synapse/storage/schema/delta/31/pushers.py
deleted file mode 100644
index 9bb504aad5..0000000000
--- a/synapse/storage/schema/delta/31/pushers.py
+++ /dev/null
@@ -1,87 +0,0 @@
-# Copyright 2016 OpenMarket Ltd
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
-# Change the last_token to last_stream_ordering now that pushers no longer
-# listen on an event stream but instead select out of the event_push_actions
-# table.
-
-
-import logging
-
-logger = logging.getLogger(__name__)
-
-
-def token_to_stream_ordering(token):
-    return int(token[1:].split("_")[0])
-
-
-def run_create(cur, database_engine, *args, **kwargs):
-    logger.info("Porting pushers table, delta 31...")
-    cur.execute(
-        """
-        CREATE TABLE IF NOT EXISTS pushers2 (
-          id BIGINT PRIMARY KEY,
-          user_name TEXT NOT NULL,
-          access_token BIGINT DEFAULT NULL,
-          profile_tag VARCHAR(32) NOT NULL,
-          kind VARCHAR(8) NOT NULL,
-          app_id VARCHAR(64) NOT NULL,
-          app_display_name VARCHAR(64) NOT NULL,
-          device_display_name VARCHAR(128) NOT NULL,
-          pushkey TEXT NOT NULL,
-          ts BIGINT NOT NULL,
-          lang VARCHAR(8),
-          data TEXT,
-          last_stream_ordering INTEGER,
-          last_success BIGINT,
-          failing_since BIGINT,
-          UNIQUE (app_id, pushkey, user_name)
-        )
-    """
-    )
-    cur.execute(
-        """SELECT
-        id, user_name, access_token, profile_tag, kind,
-        app_id, app_display_name, device_display_name,
-        pushkey, ts, lang, data, last_token, last_success,
-        failing_since
-        FROM pushers
-    """
-    )
-    count = 0
-    for row in cur.fetchall():
-        row = list(row)
-        row[12] = token_to_stream_ordering(row[12])
-        cur.execute(
-            database_engine.convert_param_style(
-                """
-            INSERT into pushers2 (
-            id, user_name, access_token, profile_tag, kind,
-            app_id, app_display_name, device_display_name,
-            pushkey, ts, lang, data, last_stream_ordering, last_success,
-            failing_since
-            ) values (%s)"""
-                % (",".join(["?" for _ in range(len(row))]))
-            ),
-            row,
-        )
-        count += 1
-    cur.execute("DROP TABLE pushers")
-    cur.execute("ALTER TABLE pushers2 RENAME TO pushers")
-    logger.info("Moved %d pushers to new table", count)
-
-
-def run_upgrade(cur, database_engine, *args, **kwargs):
-    pass
diff --git a/synapse/storage/schema/delta/31/pushers_index.sql b/synapse/storage/schema/delta/31/pushers_index.sql
deleted file mode 100644
index a82add88fd..0000000000
--- a/synapse/storage/schema/delta/31/pushers_index.sql
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Copyright 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/** Using CREATE INDEX directly is deprecated in favour of using background
- * update see synapse/storage/schema/delta/33/access_tokens_device_index.sql
- * and synapse/storage/registration.py for an example using
- * "access_tokens_device_index" **/
- CREATE INDEX event_push_actions_stream_ordering on event_push_actions(
-     stream_ordering, user_id
- );
diff --git a/synapse/storage/schema/delta/31/search_update.py b/synapse/storage/schema/delta/31/search_update.py
deleted file mode 100644
index 7d8ca5f93f..0000000000
--- a/synapse/storage/schema/delta/31/search_update.py
+++ /dev/null
@@ -1,66 +0,0 @@
-# Copyright 2016 OpenMarket Ltd
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import logging
-
-import simplejson
-
-from synapse.storage.engines import PostgresEngine
-from synapse.storage.prepare_database import get_statements
-
-logger = logging.getLogger(__name__)
-
-
-ALTER_TABLE = """
-ALTER TABLE event_search ADD COLUMN origin_server_ts BIGINT;
-ALTER TABLE event_search ADD COLUMN stream_ordering BIGINT;
-"""
-
-
-def run_create(cur, database_engine, *args, **kwargs):
-    if not isinstance(database_engine, PostgresEngine):
-        return
-
-    for statement in get_statements(ALTER_TABLE.splitlines()):
-        cur.execute(statement)
-
-    cur.execute("SELECT MIN(stream_ordering) FROM events")
-    rows = cur.fetchall()
-    min_stream_id = rows[0][0]
-
-    cur.execute("SELECT MAX(stream_ordering) FROM events")
-    rows = cur.fetchall()
-    max_stream_id = rows[0][0]
-
-    if min_stream_id is not None and max_stream_id is not None:
-        progress = {
-            "target_min_stream_id_inclusive": min_stream_id,
-            "max_stream_id_exclusive": max_stream_id + 1,
-            "rows_inserted": 0,
-            "have_added_indexes": False,
-        }
-        progress_json = simplejson.dumps(progress)
-
-        sql = (
-            "INSERT into background_updates (update_name, progress_json)"
-            " VALUES (?, ?)"
-        )
-
-        sql = database_engine.convert_param_style(sql)
-
-        cur.execute(sql, ("event_search_order", progress_json))
-
-
-def run_upgrade(cur, database_engine, *args, **kwargs):
-    pass
diff --git a/synapse/storage/schema/delta/32/openid.sql b/synapse/storage/schema/delta/32/openid.sql
deleted file mode 100644
index 36f37b11c8..0000000000
--- a/synapse/storage/schema/delta/32/openid.sql
+++ /dev/null
@@ -1,9 +0,0 @@
-
-CREATE TABLE open_id_tokens (
-    token TEXT NOT NULL PRIMARY KEY,
-    ts_valid_until_ms bigint NOT NULL,
-    user_id TEXT NOT NULL,
-    UNIQUE (token)
-);
-
-CREATE index open_id_tokens_ts_valid_until_ms ON open_id_tokens(ts_valid_until_ms);
diff --git a/synapse/storage/schema/delta/32/pusher_throttle.sql b/synapse/storage/schema/delta/32/pusher_throttle.sql
deleted file mode 100644
index d86d30c13c..0000000000
--- a/synapse/storage/schema/delta/32/pusher_throttle.sql
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Copyright 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-CREATE TABLE pusher_throttle(
-    pusher BIGINT NOT NULL,
-    room_id TEXT NOT NULL,
-    last_sent_ts BIGINT,
-    throttle_ms BIGINT,
-    PRIMARY KEY (pusher, room_id)
-);
diff --git a/synapse/storage/schema/delta/32/remove_indices.sql b/synapse/storage/schema/delta/32/remove_indices.sql
deleted file mode 100644
index 4219cdd06a..0000000000
--- a/synapse/storage/schema/delta/32/remove_indices.sql
+++ /dev/null
@@ -1,34 +0,0 @@
-/* Copyright 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
--- The following indices are redundant, other indices are equivalent or
--- supersets
-DROP INDEX IF EXISTS events_room_id; -- Prefix of events_room_stream
-DROP INDEX IF EXISTS events_order; -- Prefix of events_order_topo_stream_room
-DROP INDEX IF EXISTS events_topological_ordering; -- Prefix of events_order_topo_stream_room
-DROP INDEX IF EXISTS events_stream_ordering; -- Duplicate of PRIMARY KEY
-DROP INDEX IF EXISTS state_groups_id; -- Duplicate of PRIMARY KEY
-DROP INDEX IF EXISTS event_to_state_groups_id; -- Duplicate of PRIMARY KEY
-DROP INDEX IF EXISTS event_push_actions_room_id_event_id_user_id_profile_tag; -- Duplicate of UNIQUE CONSTRAINT
-
-DROP INDEX IF EXISTS st_extrem_id; -- Prefix of UNIQUE CONSTRAINT
-DROP INDEX IF EXISTS event_signatures_id; -- Prefix of UNIQUE CONSTRAINT
-DROP INDEX IF EXISTS redactions_event_id; -- Duplicate of UNIQUE CONSTRAINT
-
--- The following indices were unused
-DROP INDEX IF EXISTS remote_media_cache_thumbnails_media_id;
-DROP INDEX IF EXISTS evauth_edges_auth_id;
-DROP INDEX IF EXISTS presence_stream_state;
diff --git a/synapse/storage/schema/delta/32/reports.sql b/synapse/storage/schema/delta/32/reports.sql
deleted file mode 100644
index d13609776f..0000000000
--- a/synapse/storage/schema/delta/32/reports.sql
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Copyright 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-CREATE TABLE event_reports(
-    id BIGINT NOT NULL PRIMARY KEY,
-    received_ts BIGINT NOT NULL,
-    room_id TEXT NOT NULL,
-    event_id TEXT NOT NULL,
-    user_id TEXT NOT NULL,
-    reason TEXT,
-    content TEXT
-);
diff --git a/synapse/storage/schema/delta/33/access_tokens_device_index.sql b/synapse/storage/schema/delta/33/access_tokens_device_index.sql
deleted file mode 100644
index 61ad3fe3e8..0000000000
--- a/synapse/storage/schema/delta/33/access_tokens_device_index.sql
+++ /dev/null
@@ -1,17 +0,0 @@
-/* Copyright 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-INSERT INTO background_updates (update_name, progress_json) VALUES
-  ('access_tokens_device_index', '{}');
diff --git a/synapse/storage/schema/delta/33/devices.sql b/synapse/storage/schema/delta/33/devices.sql
deleted file mode 100644
index eca7268d82..0000000000
--- a/synapse/storage/schema/delta/33/devices.sql
+++ /dev/null
@@ -1,21 +0,0 @@
-/* Copyright 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-CREATE TABLE devices (
-    user_id TEXT NOT NULL,
-    device_id TEXT NOT NULL,
-    display_name TEXT,
-    CONSTRAINT device_uniqueness UNIQUE (user_id, device_id)
-);
diff --git a/synapse/storage/schema/delta/33/devices_for_e2e_keys.sql b/synapse/storage/schema/delta/33/devices_for_e2e_keys.sql
deleted file mode 100644
index aa4a3b9f2f..0000000000
--- a/synapse/storage/schema/delta/33/devices_for_e2e_keys.sql
+++ /dev/null
@@ -1,19 +0,0 @@
-/* Copyright 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
--- make sure that we have a device record for each set of E2E keys, so that the
--- user can delete them if they like.
-INSERT INTO devices
-    SELECT user_id, device_id, NULL FROM e2e_device_keys_json;
diff --git a/synapse/storage/schema/delta/33/devices_for_e2e_keys_clear_unknown_device.sql b/synapse/storage/schema/delta/33/devices_for_e2e_keys_clear_unknown_device.sql
deleted file mode 100644
index 6671573398..0000000000
--- a/synapse/storage/schema/delta/33/devices_for_e2e_keys_clear_unknown_device.sql
+++ /dev/null
@@ -1,20 +0,0 @@
-/* Copyright 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
--- a previous version of the "devices_for_e2e_keys" delta set all the device
--- names to "unknown device". This wasn't terribly helpful
-UPDATE devices
-    SET display_name = NULL
-    WHERE display_name = 'unknown device';
diff --git a/synapse/storage/schema/delta/33/event_fields.py b/synapse/storage/schema/delta/33/event_fields.py
deleted file mode 100644
index bff1256a7b..0000000000
--- a/synapse/storage/schema/delta/33/event_fields.py
+++ /dev/null
@@ -1,61 +0,0 @@
-# Copyright 2016 OpenMarket Ltd
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import logging
-
-import simplejson
-
-from synapse.storage.prepare_database import get_statements
-
-logger = logging.getLogger(__name__)
-
-
-ALTER_TABLE = """
-ALTER TABLE events ADD COLUMN sender TEXT;
-ALTER TABLE events ADD COLUMN contains_url BOOLEAN;
-"""
-
-
-def run_create(cur, database_engine, *args, **kwargs):
-    for statement in get_statements(ALTER_TABLE.splitlines()):
-        cur.execute(statement)
-
-    cur.execute("SELECT MIN(stream_ordering) FROM events")
-    rows = cur.fetchall()
-    min_stream_id = rows[0][0]
-
-    cur.execute("SELECT MAX(stream_ordering) FROM events")
-    rows = cur.fetchall()
-    max_stream_id = rows[0][0]
-
-    if min_stream_id is not None and max_stream_id is not None:
-        progress = {
-            "target_min_stream_id_inclusive": min_stream_id,
-            "max_stream_id_exclusive": max_stream_id + 1,
-            "rows_inserted": 0,
-        }
-        progress_json = simplejson.dumps(progress)
-
-        sql = (
-            "INSERT into background_updates (update_name, progress_json)"
-            " VALUES (?, ?)"
-        )
-
-        sql = database_engine.convert_param_style(sql)
-
-        cur.execute(sql, ("event_fields_sender_url", progress_json))
-
-
-def run_upgrade(cur, database_engine, *args, **kwargs):
-    pass
diff --git a/synapse/storage/schema/delta/33/remote_media_ts.py b/synapse/storage/schema/delta/33/remote_media_ts.py
deleted file mode 100644
index a26057dfb6..0000000000
--- a/synapse/storage/schema/delta/33/remote_media_ts.py
+++ /dev/null
@@ -1,30 +0,0 @@
-# Copyright 2016 OpenMarket Ltd
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import time
-
-ALTER_TABLE = "ALTER TABLE remote_media_cache ADD COLUMN last_access_ts BIGINT"
-
-
-def run_create(cur, database_engine, *args, **kwargs):
-    cur.execute(ALTER_TABLE)
-
-
-def run_upgrade(cur, database_engine, *args, **kwargs):
-    cur.execute(
-        database_engine.convert_param_style(
-            "UPDATE remote_media_cache SET last_access_ts = ?"
-        ),
-        (int(time.time() * 1000),),
-    )
diff --git a/synapse/storage/schema/delta/33/user_ips_index.sql b/synapse/storage/schema/delta/33/user_ips_index.sql
deleted file mode 100644
index 473f75a78e..0000000000
--- a/synapse/storage/schema/delta/33/user_ips_index.sql
+++ /dev/null
@@ -1,17 +0,0 @@
-/* Copyright 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-INSERT INTO background_updates (update_name, progress_json) VALUES
-  ('user_ips_device_index', '{}');
diff --git a/synapse/storage/schema/delta/34/appservice_stream.sql b/synapse/storage/schema/delta/34/appservice_stream.sql
deleted file mode 100644
index 69e16eda0f..0000000000
--- a/synapse/storage/schema/delta/34/appservice_stream.sql
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Copyright 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-CREATE TABLE IF NOT EXISTS appservice_stream_position(
-    Lock CHAR(1) NOT NULL DEFAULT 'X' UNIQUE,  -- Makes sure this table only has one row.
-    stream_ordering BIGINT,
-    CHECK (Lock='X')
-);
-
-INSERT INTO appservice_stream_position (stream_ordering)
-    SELECT COALESCE(MAX(stream_ordering), 0) FROM events;
diff --git a/synapse/storage/schema/delta/34/cache_stream.py b/synapse/storage/schema/delta/34/cache_stream.py
deleted file mode 100644
index cf09e43e2b..0000000000
--- a/synapse/storage/schema/delta/34/cache_stream.py
+++ /dev/null
@@ -1,46 +0,0 @@
-# Copyright 2016 OpenMarket Ltd
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import logging
-
-from synapse.storage.engines import PostgresEngine
-from synapse.storage.prepare_database import get_statements
-
-logger = logging.getLogger(__name__)
-
-
-# This stream is used to notify replication slaves that some caches have
-# been invalidated that they cannot infer from the other streams.
-CREATE_TABLE = """
-CREATE TABLE cache_invalidation_stream (
-    stream_id       BIGINT,
-    cache_func      TEXT,
-    keys            TEXT[],
-    invalidation_ts BIGINT
-);
-
-CREATE INDEX cache_invalidation_stream_id ON cache_invalidation_stream(stream_id);
-"""
-
-
-def run_create(cur, database_engine, *args, **kwargs):
-    if not isinstance(database_engine, PostgresEngine):
-        return
-
-    for statement in get_statements(CREATE_TABLE.splitlines()):
-        cur.execute(statement)
-
-
-def run_upgrade(cur, database_engine, *args, **kwargs):
-    pass
diff --git a/synapse/storage/schema/delta/34/device_inbox.sql b/synapse/storage/schema/delta/34/device_inbox.sql
deleted file mode 100644
index e68844c74a..0000000000
--- a/synapse/storage/schema/delta/34/device_inbox.sql
+++ /dev/null
@@ -1,24 +0,0 @@
-/* Copyright 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-CREATE TABLE device_inbox (
-    user_id TEXT NOT NULL,
-    device_id TEXT NOT NULL,
-    stream_id BIGINT NOT NULL,
-    message_json TEXT NOT NULL -- {"type":, "sender":, "content",}
-);
-
-CREATE INDEX device_inbox_user_stream_id ON device_inbox(user_id, device_id, stream_id);
-CREATE INDEX device_inbox_stream_id ON device_inbox(stream_id);
diff --git a/synapse/storage/schema/delta/34/push_display_name_rename.sql b/synapse/storage/schema/delta/34/push_display_name_rename.sql
deleted file mode 100644
index 0d9fe1a99a..0000000000
--- a/synapse/storage/schema/delta/34/push_display_name_rename.sql
+++ /dev/null
@@ -1,20 +0,0 @@
-/* Copyright 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-DELETE FROM push_rules WHERE rule_id = 'global/override/.m.rule.contains_display_name';
-UPDATE push_rules SET rule_id = 'global/override/.m.rule.contains_display_name' WHERE rule_id = 'global/underride/.m.rule.contains_display_name';
-
-DELETE FROM push_rules_enable WHERE rule_id = 'global/override/.m.rule.contains_display_name';
-UPDATE push_rules_enable SET rule_id = 'global/override/.m.rule.contains_display_name' WHERE rule_id = 'global/underride/.m.rule.contains_display_name';
diff --git a/synapse/storage/schema/delta/34/received_txn_purge.py b/synapse/storage/schema/delta/34/received_txn_purge.py
deleted file mode 100644
index 67d505e68b..0000000000
--- a/synapse/storage/schema/delta/34/received_txn_purge.py
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright 2016 OpenMarket Ltd
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import logging
-
-from synapse.storage.engines import PostgresEngine
-
-logger = logging.getLogger(__name__)
-
-
-def run_create(cur, database_engine, *args, **kwargs):
-    if isinstance(database_engine, PostgresEngine):
-        cur.execute("TRUNCATE received_transactions")
-    else:
-        cur.execute("DELETE FROM received_transactions")
-
-    cur.execute("CREATE INDEX received_transactions_ts ON received_transactions(ts)")
-
-
-def run_upgrade(cur, database_engine, *args, **kwargs):
-    pass
diff --git a/synapse/storage/schema/delta/32/events.sql b/synapse/storage/schema/delta/35/00background_updates_add_col.sql
index 1dd0f9e170..c2d2a4f836 100644
--- a/synapse/storage/schema/delta/32/events.sql
+++ b/synapse/storage/schema/delta/35/00background_updates_add_col.sql
@@ -13,4 +13,5 @@
  * limitations under the License.
  */
 
-ALTER TABLE events ADD COLUMN received_ts BIGINT;
+
+ALTER TABLE background_updates ADD COLUMN depends_on TEXT;
diff --git a/synapse/storage/schema/delta/35/add_state_index.sql b/synapse/storage/schema/delta/35/add_state_index.sql
deleted file mode 100644
index 0fce26345b..0000000000
--- a/synapse/storage/schema/delta/35/add_state_index.sql
+++ /dev/null
@@ -1,20 +0,0 @@
-/* Copyright 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-ALTER TABLE background_updates ADD COLUMN depends_on TEXT;
-
-INSERT into background_updates (update_name, progress_json, depends_on)
-    VALUES ('state_group_state_type_index', '{}', 'state_group_state_deduplication');
diff --git a/synapse/storage/schema/delta/35/contains_url.sql b/synapse/storage/schema/delta/35/contains_url.sql
deleted file mode 100644
index 6cd123027b..0000000000
--- a/synapse/storage/schema/delta/35/contains_url.sql
+++ /dev/null
@@ -1,17 +0,0 @@
-/* Copyright 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
- INSERT into background_updates (update_name, progress_json)
-     VALUES ('event_contains_url_index', '{}');
diff --git a/synapse/storage/schema/delta/35/device_outbox.sql b/synapse/storage/schema/delta/35/device_outbox.sql
deleted file mode 100644
index 17e6c43105..0000000000
--- a/synapse/storage/schema/delta/35/device_outbox.sql
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Copyright 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-DROP TABLE IF EXISTS device_federation_outbox;
-CREATE TABLE device_federation_outbox (
-    destination TEXT NOT NULL,
-    stream_id BIGINT NOT NULL,
-    queued_ts BIGINT NOT NULL,
-    messages_json TEXT NOT NULL
-);
-
-
-DROP INDEX IF EXISTS device_federation_outbox_destination_id;
-CREATE INDEX device_federation_outbox_destination_id
-    ON device_federation_outbox(destination, stream_id);
-
-
-DROP TABLE IF EXISTS device_federation_inbox;
-CREATE TABLE device_federation_inbox (
-    origin TEXT NOT NULL,
-    message_id TEXT NOT NULL,
-    received_ts BIGINT NOT NULL
-);
-
-DROP INDEX IF EXISTS device_federation_inbox_sender_id;
-CREATE INDEX device_federation_inbox_sender_id
-    ON device_federation_inbox(origin, message_id);
diff --git a/synapse/storage/schema/delta/35/device_stream_id.sql b/synapse/storage/schema/delta/35/device_stream_id.sql
deleted file mode 100644
index 7ab7d942e2..0000000000
--- a/synapse/storage/schema/delta/35/device_stream_id.sql
+++ /dev/null
@@ -1,21 +0,0 @@
-/* Copyright 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-CREATE TABLE device_max_stream_id (
-    stream_id BIGINT NOT NULL
-);
-
-INSERT INTO device_max_stream_id (stream_id)
-    SELECT COALESCE(MAX(stream_id), 0) FROM device_inbox;
diff --git a/synapse/storage/schema/delta/35/event_push_actions_index.sql b/synapse/storage/schema/delta/35/event_push_actions_index.sql
deleted file mode 100644
index 2e836d8e9c..0000000000
--- a/synapse/storage/schema/delta/35/event_push_actions_index.sql
+++ /dev/null
@@ -1,17 +0,0 @@
-/* Copyright 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
- INSERT into background_updates (update_name, progress_json)
-     VALUES ('epa_highlight_index', '{}');
diff --git a/synapse/storage/schema/delta/35/public_room_list_change_stream.sql b/synapse/storage/schema/delta/35/public_room_list_change_stream.sql
deleted file mode 100644
index dd2bf2e28a..0000000000
--- a/synapse/storage/schema/delta/35/public_room_list_change_stream.sql
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Copyright 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-CREATE TABLE public_room_list_stream (
-    stream_id BIGINT NOT NULL,
-    room_id TEXT NOT NULL,
-    visibility BOOLEAN NOT NULL
-);
-
-INSERT INTO public_room_list_stream (stream_id, room_id, visibility)
-    SELECT 1, room_id, is_public FROM rooms
-    WHERE is_public = CAST(1 AS BOOLEAN);
-
-CREATE INDEX public_room_list_stream_idx on public_room_list_stream(
-    stream_id
-);
-
-CREATE INDEX public_room_list_stream_rm_idx on public_room_list_stream(
-    room_id, stream_id
-);
diff --git a/synapse/storage/schema/delta/35/state.sql b/synapse/storage/schema/delta/35/state.sql
deleted file mode 100644
index 0f1fa68a89..0000000000
--- a/synapse/storage/schema/delta/35/state.sql
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Copyright 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-CREATE TABLE state_group_edges(
-    state_group BIGINT NOT NULL,
-    prev_state_group BIGINT NOT NULL
-);
-
-CREATE INDEX state_group_edges_idx ON state_group_edges(state_group);
-CREATE INDEX state_group_edges_prev_idx ON state_group_edges(prev_state_group);
diff --git a/synapse/storage/schema/delta/35/state_dedupe.sql b/synapse/storage/schema/delta/35/state_dedupe.sql
deleted file mode 100644
index 97e5067ef4..0000000000
--- a/synapse/storage/schema/delta/35/state_dedupe.sql
+++ /dev/null
@@ -1,17 +0,0 @@
-/* Copyright 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-INSERT into background_updates (update_name, progress_json)
-    VALUES ('state_group_state_deduplication', '{}');
diff --git a/synapse/storage/schema/delta/35/stream_order_to_extrem.sql b/synapse/storage/schema/delta/35/stream_order_to_extrem.sql
deleted file mode 100644
index 2b945d8a57..0000000000
--- a/synapse/storage/schema/delta/35/stream_order_to_extrem.sql
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Copyright 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-CREATE TABLE stream_ordering_to_exterm (
-    stream_ordering BIGINT NOT NULL,
-    room_id TEXT NOT NULL,
-    event_id TEXT NOT NULL
-);
-
-INSERT INTO stream_ordering_to_exterm (stream_ordering, room_id, event_id)
-    SELECT stream_ordering, room_id, event_id FROM event_forward_extremities
-    INNER JOIN (
-        SELECT room_id, max(stream_ordering) as stream_ordering FROM events
-        INNER JOIN event_forward_extremities USING (room_id, event_id)
-        GROUP BY room_id
-    ) AS rms USING (room_id);
-
-CREATE INDEX stream_ordering_to_exterm_idx on stream_ordering_to_exterm(
-    stream_ordering
-);
-
-CREATE INDEX stream_ordering_to_exterm_rm_idx on stream_ordering_to_exterm(
-    room_id, stream_ordering
-);
diff --git a/synapse/storage/schema/delta/36/readd_public_rooms.sql b/synapse/storage/schema/delta/36/readd_public_rooms.sql
deleted file mode 100644
index 90d8fd18f9..0000000000
--- a/synapse/storage/schema/delta/36/readd_public_rooms.sql
+++ /dev/null
@@ -1,26 +0,0 @@
-/* Copyright 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
--- Re-add some entries to stream_ordering_to_exterm that were incorrectly deleted
-INSERT INTO stream_ordering_to_exterm (stream_ordering, room_id, event_id)
-    SELECT
-        (SELECT stream_ordering FROM events where event_id = e.event_id) AS stream_ordering,
-        room_id,
-        event_id
-    FROM event_forward_extremities AS e
-    WHERE NOT EXISTS (
-        SELECT room_id FROM stream_ordering_to_exterm AS s
-        WHERE s.room_id = e.room_id
-    );
diff --git a/synapse/storage/schema/delta/37/remove_auth_idx.py b/synapse/storage/schema/delta/37/remove_auth_idx.py
deleted file mode 100644
index a377884169..0000000000
--- a/synapse/storage/schema/delta/37/remove_auth_idx.py
+++ /dev/null
@@ -1,85 +0,0 @@
-# Copyright 2016 OpenMarket Ltd
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import logging
-
-from synapse.storage.engines import PostgresEngine
-from synapse.storage.prepare_database import get_statements
-
-logger = logging.getLogger(__name__)
-
-DROP_INDICES = """
--- We only ever query based on event_id
-DROP INDEX IF EXISTS state_events_room_id;
-DROP INDEX IF EXISTS state_events_type;
-DROP INDEX IF EXISTS state_events_state_key;
-
--- room_id is indexed elsewhere
-DROP INDEX IF EXISTS current_state_events_room_id;
-DROP INDEX IF EXISTS current_state_events_state_key;
-DROP INDEX IF EXISTS current_state_events_type;
-
-DROP INDEX IF EXISTS transactions_have_ref;
-
--- (topological_ordering, stream_ordering, room_id) seems like a strange index,
--- and is used incredibly rarely.
-DROP INDEX IF EXISTS events_order_topo_stream_room;
-
--- an equivalent index to this actually gets re-created in delta 41, because it
--- turned out that deleting it wasn't a great plan :/. In any case, let's
--- delete it here, and delta 41 will create a new one with an added UNIQUE
--- constraint
-DROP INDEX IF EXISTS event_search_ev_idx;
-"""
-
-POSTGRES_DROP_CONSTRAINT = """
-ALTER TABLE event_auth DROP CONSTRAINT IF EXISTS event_auth_event_id_auth_id_room_id_key;
-"""
-
-SQLITE_DROP_CONSTRAINT = """
-DROP INDEX IF EXISTS evauth_edges_id;
-
-CREATE TABLE IF NOT EXISTS event_auth_new(
-    event_id TEXT NOT NULL,
-    auth_id TEXT NOT NULL,
-    room_id TEXT NOT NULL
-);
-
-INSERT INTO event_auth_new
-    SELECT event_id, auth_id, room_id
-    FROM event_auth;
-
-DROP TABLE event_auth;
-
-ALTER TABLE event_auth_new RENAME TO event_auth;
-
-CREATE INDEX evauth_edges_id ON event_auth(event_id);
-"""
-
-
-def run_create(cur, database_engine, *args, **kwargs):
-    for statement in get_statements(DROP_INDICES.splitlines()):
-        cur.execute(statement)
-
-    if isinstance(database_engine, PostgresEngine):
-        drop_constraint = POSTGRES_DROP_CONSTRAINT
-    else:
-        drop_constraint = SQLITE_DROP_CONSTRAINT
-
-    for statement in get_statements(drop_constraint.splitlines()):
-        cur.execute(statement)
-
-
-def run_upgrade(cur, database_engine, *args, **kwargs):
-    pass
diff --git a/synapse/storage/schema/delta/37/user_threepids.sql b/synapse/storage/schema/delta/37/user_threepids.sql
deleted file mode 100644
index cf7a90dd10..0000000000
--- a/synapse/storage/schema/delta/37/user_threepids.sql
+++ /dev/null
@@ -1,52 +0,0 @@
-/* Copyright 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * Update any email addresses that were stored with mixed case into all
- * lowercase
- */
-
- -- There may be "duplicate" emails (with different case) already in the table,
- -- so we find them and move all but the most recently used account.
- UPDATE user_threepids
- SET medium = 'email_old'
- WHERE medium = 'email'
-    AND address IN (
-         -- We select all the addresses that are linked to the user_id that is NOT
-         -- the most recently created.
-         SELECT u.address
-         FROM
-             user_threepids AS u,
-             -- `duplicate_addresses` is a table of all the email addresses that
-             -- appear multiple times and when the binding was created
-             (
-                 SELECT lower(u1.address) AS address, max(u1.added_at) AS max_ts
-                 FROM user_threepids AS u1
-                 INNER JOIN user_threepids AS u2 ON u1.medium = u2.medium AND lower(u1.address) = lower(u2.address) AND u1.address != u2.address
-                 WHERE u1.medium = 'email' AND u2.medium = 'email'
-                 GROUP BY lower(u1.address)
-             ) AS duplicate_addresses
-         WHERE
-             lower(u.address) = duplicate_addresses.address
-             AND u.added_at != max_ts  -- NOT the most recently created
-     );
-
-
--- This update is now safe since we've removed the duplicate addresses.
-UPDATE user_threepids SET address = LOWER(address) WHERE medium = 'email';
-
-
-/* Add an index for the select we do on passwored reset */
-CREATE INDEX user_threepids_medium_address on user_threepids (medium, address);
diff --git a/synapse/storage/schema/delta/38/postgres_fts_gist.sql b/synapse/storage/schema/delta/38/postgres_fts_gist.sql
deleted file mode 100644
index 515e6b8e84..0000000000
--- a/synapse/storage/schema/delta/38/postgres_fts_gist.sql
+++ /dev/null
@@ -1,19 +0,0 @@
-/* Copyright 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
--- We no longer do this given we back it out again in schema 47
-
--- INSERT into background_updates (update_name, progress_json)
---     VALUES ('event_search_postgres_gist', '{}');
diff --git a/synapse/storage/schema/delta/39/appservice_room_list.sql b/synapse/storage/schema/delta/39/appservice_room_list.sql
deleted file mode 100644
index 74bdc49073..0000000000
--- a/synapse/storage/schema/delta/39/appservice_room_list.sql
+++ /dev/null
@@ -1,29 +0,0 @@
-/* Copyright 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-CREATE TABLE appservice_room_list(
-    appservice_id TEXT NOT NULL,
-    network_id TEXT NOT NULL,
-    room_id TEXT NOT NULL
-);
-
--- Each appservice can have multiple published room lists associated with them,
--- keyed of a particular network_id
-CREATE UNIQUE INDEX appservice_room_list_idx ON appservice_room_list(
-    appservice_id, network_id, room_id
-);
-
-ALTER TABLE public_room_list_stream ADD COLUMN appservice_id TEXT;
-ALTER TABLE public_room_list_stream ADD COLUMN network_id TEXT;
diff --git a/synapse/storage/schema/delta/39/device_federation_stream_idx.sql b/synapse/storage/schema/delta/39/device_federation_stream_idx.sql
deleted file mode 100644
index 00be801e90..0000000000
--- a/synapse/storage/schema/delta/39/device_federation_stream_idx.sql
+++ /dev/null
@@ -1,16 +0,0 @@
-/* Copyright 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-CREATE INDEX device_federation_outbox_id ON device_federation_outbox(stream_id);
diff --git a/synapse/storage/schema/delta/39/event_push_index.sql b/synapse/storage/schema/delta/39/event_push_index.sql
deleted file mode 100644
index de2ad93e5c..0000000000
--- a/synapse/storage/schema/delta/39/event_push_index.sql
+++ /dev/null
@@ -1,17 +0,0 @@
-/* Copyright 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-INSERT INTO background_updates (update_name, progress_json) VALUES
-  ('event_push_actions_highlights_index', '{}');
diff --git a/synapse/storage/schema/delta/39/federation_out_position.sql b/synapse/storage/schema/delta/39/federation_out_position.sql
deleted file mode 100644
index 5af814290b..0000000000
--- a/synapse/storage/schema/delta/39/federation_out_position.sql
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Copyright 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
- CREATE TABLE federation_stream_position(
-     type TEXT NOT NULL,
-     stream_id INTEGER NOT NULL
- );
-
- INSERT INTO federation_stream_position (type, stream_id) VALUES ('federation', -1);
- INSERT INTO federation_stream_position (type, stream_id) SELECT 'events', coalesce(max(stream_ordering), -1) FROM events;
diff --git a/synapse/storage/schema/delta/39/membership_profile.sql b/synapse/storage/schema/delta/39/membership_profile.sql
deleted file mode 100644
index 1bf911c8ab..0000000000
--- a/synapse/storage/schema/delta/39/membership_profile.sql
+++ /dev/null
@@ -1,20 +0,0 @@
-/* Copyright 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-ALTER TABLE room_memberships ADD COLUMN display_name TEXT;
-ALTER TABLE room_memberships ADD COLUMN avatar_url TEXT;
-
-INSERT into background_updates (update_name, progress_json)
-    VALUES ('room_membership_profile_update', '{}');
diff --git a/synapse/storage/schema/delta/40/current_state_idx.sql b/synapse/storage/schema/delta/40/current_state_idx.sql
deleted file mode 100644
index 7ffa189f39..0000000000
--- a/synapse/storage/schema/delta/40/current_state_idx.sql
+++ /dev/null
@@ -1,17 +0,0 @@
-/* Copyright 2017 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-INSERT INTO background_updates (update_name, progress_json) VALUES
-  ('current_state_members_idx', '{}');
diff --git a/synapse/storage/schema/delta/40/device_inbox.sql b/synapse/storage/schema/delta/40/device_inbox.sql
deleted file mode 100644
index b9fe1f0480..0000000000
--- a/synapse/storage/schema/delta/40/device_inbox.sql
+++ /dev/null
@@ -1,21 +0,0 @@
-/* Copyright 2016 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
--- turn the pre-fill startup query into a index-only scan on postgresql.
-INSERT into background_updates (update_name, progress_json)
-    VALUES ('device_inbox_stream_index', '{}');
-
-INSERT into background_updates (update_name, progress_json, depends_on)
-    VALUES ('device_inbox_stream_drop', '{}', 'device_inbox_stream_index');
diff --git a/synapse/storage/schema/delta/40/device_list_streams.sql b/synapse/storage/schema/delta/40/device_list_streams.sql
deleted file mode 100644
index dd6dcb65f1..0000000000
--- a/synapse/storage/schema/delta/40/device_list_streams.sql
+++ /dev/null
@@ -1,60 +0,0 @@
-/* Copyright 2017 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
--- Cache of remote devices.
-CREATE TABLE device_lists_remote_cache (
-    user_id TEXT NOT NULL,
-    device_id TEXT NOT NULL,
-    content TEXT NOT NULL
-);
-
--- The last update we got for a user. Empty if we're not receiving updates for
--- that user.
-CREATE TABLE device_lists_remote_extremeties (
-    user_id TEXT NOT NULL,
-    stream_id TEXT NOT NULL
-);
-
--- we used to create non-unique indexes on these tables, but as of update 52 we create
--- unique indexes concurrently:
---
--- CREATE INDEX device_lists_remote_cache_id ON device_lists_remote_cache(user_id, device_id);
--- CREATE INDEX device_lists_remote_extremeties_id ON device_lists_remote_extremeties(user_id, stream_id);
-
-
--- Stream of device lists updates. Includes both local and remotes
-CREATE TABLE device_lists_stream (
-    stream_id BIGINT NOT NULL,
-    user_id TEXT NOT NULL,
-    device_id TEXT NOT NULL
-);
-
-CREATE INDEX device_lists_stream_id ON device_lists_stream(stream_id, user_id);
-
-
--- The stream of updates to send to other servers. We keep at least one row
--- per user that was sent so that the prev_id for any new updates can be
--- calculated
-CREATE TABLE device_lists_outbound_pokes (
-    destination TEXT NOT NULL,
-    stream_id BIGINT NOT NULL,
-    user_id TEXT NOT NULL,
-    device_id TEXT NOT NULL,
-    sent BOOLEAN NOT NULL,
-    ts BIGINT NOT NULL  -- So that in future we can clear out pokes to dead servers
-);
-
-CREATE INDEX device_lists_outbound_pokes_id ON device_lists_outbound_pokes(destination, stream_id);
-CREATE INDEX device_lists_outbound_pokes_user ON device_lists_outbound_pokes(destination, user_id);
diff --git a/synapse/storage/schema/delta/40/event_push_summary.sql b/synapse/storage/schema/delta/40/event_push_summary.sql
deleted file mode 100644
index 3918f0b794..0000000000
--- a/synapse/storage/schema/delta/40/event_push_summary.sql
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Copyright 2017 OpenMarket Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
--- Aggregate of old notification counts that have been deleted out of the
--- main event_push_actions table. This count does not include those that were
--- highlights, as they remain in the event_push_actions table.
-CREATE TABLE event_push_summary (
-    user_id TEXT NOT NULL,
-    room_id TEXT NOT NULL,
-    notif_count BIGINT NOT NULL,
-    stream_ordering BIGINT NOT NULL
-);
-
-CREATE INDEX event_push_summary_user_rm ON event_push_summary(user_id, room_id);
-
-
--- The stream ordering up to which we have aggregated the event_push_actions
--- table into event_push_summary
-CREATE TABLE event_push_summary_stream_ordering (
-    Lock CHAR(1) NOT NULL DEFAULT 'X' UNIQUE,  -- Makes sure this table only has one row.
-    stream_ordering BIGINT NOT NULL,
-    CHECK (Lock='X')
-);
-
-INSERT INTO event_push_summary_stream_ordering (stream_ordering) VALUES (0);
diff --git a/synapse/storage/schema/delta/40/pushers.sql b/synapse/storage/schema/delta/40/pushers.sql
deleted file mode 100644
index 054a223f14..0000000000
--- a/synapse/storage/schema/delta/40/pushers.sql
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Copyright 2017 Vector Creations Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-CREATE TABLE IF NOT EXISTS pushers2 (
-    id BIGINT PRIMARY KEY,
-    user_name TEXT NOT NULL,
-    access_token BIGINT DEFAULT NULL,
-    profile_tag TEXT NOT NULL,
-    kind TEXT NOT NULL,
-    app_id TEXT NOT NULL,
-    app_display_name TEXT NOT NULL,
-    device_display_name TEXT NOT NULL,
-    pushkey TEXT NOT NULL,
-    ts BIGINT NOT NULL,
-    lang TEXT,
-    data TEXT,
-    last_stream_ordering INTEGER,
-    last_success BIGINT,
-    failing_since BIGINT,
-    UNIQUE (app_id, pushkey, user_name)
-);
-
-INSERT INTO pushers2 SELECT * FROM PUSHERS;
-
-DROP TABLE PUSHERS;
-
-ALTER TABLE pushers2 RENAME TO pushers;
diff --git a/synapse/storage/schema/delta/41/device_list_stream_idx.sql b/synapse/storage/schema/delta/41/device_list_stream_idx.sql
deleted file mode 100644
index b7bee8b692..0000000000
--- a/synapse/storage/schema/delta/41/device_list_stream_idx.sql
+++ /dev/null
@@ -1,17 +0,0 @@
-/* Copyright 2017 Vector Creations Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-INSERT into background_updates (update_name, progress_json)
-    VALUES ('device_lists_stream_idx', '{}');
diff --git a/synapse/storage/schema/delta/41/device_outbound_index.sql b/synapse/storage/schema/delta/41/device_outbound_index.sql
deleted file mode 100644
index 62f0b9892b..0000000000
--- a/synapse/storage/schema/delta/41/device_outbound_index.sql
+++ /dev/null
@@ -1,16 +0,0 @@
-/* Copyright 2017 Vector Creations Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-CREATE INDEX device_lists_outbound_pokes_stream ON device_lists_outbound_pokes(stream_id);
diff --git a/synapse/storage/schema/delta/41/event_search_event_id_idx.sql b/synapse/storage/schema/delta/41/event_search_event_id_idx.sql
deleted file mode 100644
index 5d9cfecf36..0000000000
--- a/synapse/storage/schema/delta/41/event_search_event_id_idx.sql
+++ /dev/null
@@ -1,17 +0,0 @@
-/* Copyright 2017 Vector Creations Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-INSERT into background_updates (update_name, progress_json)
-    VALUES ('event_search_event_id_idx', '{}');
diff --git a/synapse/storage/schema/delta/41/ratelimit.sql b/synapse/storage/schema/delta/41/ratelimit.sql
deleted file mode 100644
index a194bf0238..0000000000
--- a/synapse/storage/schema/delta/41/ratelimit.sql
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Copyright 2017 Vector Creations Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-CREATE TABLE ratelimit_override (
-    user_id TEXT NOT NULL,
-    messages_per_second BIGINT,
-    burst_count BIGINT
-);
-
-CREATE UNIQUE INDEX ratelimit_override_idx ON ratelimit_override(user_id);
diff --git a/synapse/storage/schema/delta/42/current_state_delta.sql b/synapse/storage/schema/delta/42/current_state_delta.sql
deleted file mode 100644
index d28851aff8..0000000000
--- a/synapse/storage/schema/delta/42/current_state_delta.sql
+++ /dev/null
@@ -1,26 +0,0 @@
-/* Copyright 2017 Vector Creations Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-CREATE TABLE current_state_delta_stream (
-    stream_id BIGINT NOT NULL,
-    room_id TEXT NOT NULL,
-    type TEXT NOT NULL,
-    state_key TEXT NOT NULL,
-    event_id TEXT,  -- Is null if the key was removed
-    prev_event_id TEXT  -- Is null if the key was added
-);
-
-CREATE INDEX current_state_delta_stream_idx ON current_state_delta_stream(stream_id);
diff --git a/synapse/storage/schema/delta/42/device_list_last_id.sql b/synapse/storage/schema/delta/42/device_list_last_id.sql
deleted file mode 100644
index 9ab8c14fa3..0000000000
--- a/synapse/storage/schema/delta/42/device_list_last_id.sql
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Copyright 2017 Vector Creations Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
--- Table of last stream_id that we sent to destination for user_id. This is
--- used to fill out the `prev_id` fields of outbound device list updates.
-CREATE TABLE device_lists_outbound_last_success (
-    destination TEXT NOT NULL,
-    user_id TEXT NOT NULL,
-    stream_id BIGINT NOT NULL
-);
-
-INSERT INTO device_lists_outbound_last_success
-    SELECT destination, user_id, coalesce(max(stream_id), 0) as stream_id
-        FROM device_lists_outbound_pokes
-        WHERE sent = (1 = 1)  -- sqlite doesn't have inbuilt boolean values
-        GROUP BY destination, user_id;
-
-CREATE INDEX device_lists_outbound_last_success_idx ON device_lists_outbound_last_success(
-    destination, user_id, stream_id
-);
diff --git a/synapse/storage/schema/delta/42/event_auth_state_only.sql b/synapse/storage/schema/delta/42/event_auth_state_only.sql
deleted file mode 100644
index b8821ac759..0000000000
--- a/synapse/storage/schema/delta/42/event_auth_state_only.sql
+++ /dev/null
@@ -1,17 +0,0 @@
-/* Copyright 2017 Vector Creations Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-INSERT INTO background_updates (update_name, progress_json) VALUES
-  ('event_auth_state_only', '{}');
diff --git a/synapse/storage/schema/delta/42/user_dir.py b/synapse/storage/schema/delta/42/user_dir.py
deleted file mode 100644
index 506f326f4d..0000000000
--- a/synapse/storage/schema/delta/42/user_dir.py
+++ /dev/null
@@ -1,84 +0,0 @@
-# Copyright 2017 Vector Creations Ltd
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import logging
-
-from synapse.storage.engines import PostgresEngine, Sqlite3Engine
-from synapse.storage.prepare_database import get_statements
-
-logger = logging.getLogger(__name__)
-
-
-BOTH_TABLES = """
-CREATE TABLE user_directory_stream_pos (
-    Lock CHAR(1) NOT NULL DEFAULT 'X' UNIQUE,  -- Makes sure this table only has one row.
-    stream_id BIGINT,
-    CHECK (Lock='X')
-);
-
-INSERT INTO user_directory_stream_pos (stream_id) VALUES (null);
-
-CREATE TABLE user_directory (
-    user_id TEXT NOT NULL,
-    room_id TEXT NOT NULL,  -- A room_id that we know the user is joined to
-    display_name TEXT,
-    avatar_url TEXT
-);
-
-CREATE INDEX user_directory_room_idx ON user_directory(room_id);
-CREATE UNIQUE INDEX user_directory_user_idx ON user_directory(user_id);
-
-CREATE TABLE users_in_pubic_room (
-    user_id TEXT NOT NULL,
-    room_id TEXT NOT NULL  -- A room_id that we know is public
-);
-
-CREATE INDEX users_in_pubic_room_room_idx ON users_in_pubic_room(room_id);
-CREATE UNIQUE INDEX users_in_pubic_room_user_idx ON users_in_pubic_room(user_id);
-"""
-
-
-POSTGRES_TABLE = """
-CREATE TABLE user_directory_search (
-    user_id TEXT NOT NULL,
-    vector tsvector
-);
-
-CREATE INDEX user_directory_search_fts_idx ON user_directory_search USING gin(vector);
-CREATE UNIQUE INDEX user_directory_search_user_idx ON user_directory_search(user_id);
-"""
-
-
-SQLITE_TABLE = """
-CREATE VIRTUAL TABLE user_directory_search
-    USING fts4 ( user_id, value );
-"""
-
-
-def run_create(cur, database_engine, *args, **kwargs):
-    for statement in get_statements(BOTH_TABLES.splitlines()):
-        cur.execute(statement)
-
-    if isinstance(database_engine, PostgresEngine):
-        for statement in get_statements(POSTGRES_TABLE.splitlines()):
-            cur.execute(statement)
-    elif isinstance(database_engine, Sqlite3Engine):
-        for statement in get_statements(SQLITE_TABLE.splitlines()):
-            cur.execute(statement)
-    else:
-        raise Exception("Unrecognized database engine")
-
-
-def run_upgrade(*args, **kwargs):
-    pass
diff --git a/synapse/storage/schema/delta/43/blocked_rooms.sql b/synapse/storage/schema/delta/43/blocked_rooms.sql
deleted file mode 100644
index 0e3cd143ff..0000000000
--- a/synapse/storage/schema/delta/43/blocked_rooms.sql
+++ /dev/null
@@ -1,21 +0,0 @@
-/* Copyright 2017 Vector Creations Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-CREATE TABLE blocked_rooms (
-    room_id TEXT NOT NULL,
-    user_id TEXT NOT NULL  -- Admin who blocked the room
-);
-
-CREATE UNIQUE INDEX blocked_rooms_idx ON blocked_rooms(room_id);
diff --git a/synapse/storage/schema/delta/43/quarantine_media.sql b/synapse/storage/schema/delta/43/quarantine_media.sql
deleted file mode 100644
index 630907ec4f..0000000000
--- a/synapse/storage/schema/delta/43/quarantine_media.sql
+++ /dev/null
@@ -1,17 +0,0 @@
-/* Copyright 2017 Vector Creations Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-ALTER TABLE local_media_repository ADD COLUMN quarantined_by TEXT;
-ALTER TABLE remote_media_cache ADD COLUMN quarantined_by TEXT;
diff --git a/synapse/storage/schema/delta/43/url_cache.sql b/synapse/storage/schema/delta/43/url_cache.sql
deleted file mode 100644
index 45ebe020da..0000000000
--- a/synapse/storage/schema/delta/43/url_cache.sql
+++ /dev/null
@@ -1,16 +0,0 @@
-/* Copyright 2017 Vector Creations Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-ALTER TABLE local_media_repository ADD COLUMN url_cache TEXT;
diff --git a/synapse/storage/schema/delta/43/user_share.sql b/synapse/storage/schema/delta/43/user_share.sql
deleted file mode 100644
index ee7062abe4..0000000000
--- a/synapse/storage/schema/delta/43/user_share.sql
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Copyright 2017 Vector Creations Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
--- Table keeping track of who shares a room with who. We only keep track
--- of this for local users, so `user_id` is local users only (but we do keep track
--- of which remote users share a room)
-CREATE TABLE users_who_share_rooms (
-    user_id TEXT NOT NULL,
-    other_user_id TEXT NOT NULL,
-    room_id TEXT NOT NULL,
-    share_private BOOLEAN NOT NULL  -- is the shared room private? i.e. they share a private room
-);
-
-
-CREATE UNIQUE INDEX users_who_share_rooms_u_idx ON users_who_share_rooms(user_id, other_user_id);
-CREATE INDEX users_who_share_rooms_r_idx ON users_who_share_rooms(room_id);
-CREATE INDEX users_who_share_rooms_o_idx ON users_who_share_rooms(other_user_id);
-
-
--- Make sure that we populate the table initially
-UPDATE user_directory_stream_pos SET stream_id = NULL;
diff --git a/synapse/storage/schema/delta/44/expire_url_cache.sql b/synapse/storage/schema/delta/44/expire_url_cache.sql
deleted file mode 100644
index b12f9b2ebf..0000000000
--- a/synapse/storage/schema/delta/44/expire_url_cache.sql
+++ /dev/null
@@ -1,41 +0,0 @@
-/* Copyright 2017 New Vector Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
--- this didn't work on SQLite 3.7 (because of lack of partial indexes), so was
--- removed and replaced with 46/local_media_repository_url_idx.sql.
---
--- CREATE INDEX local_media_repository_url_idx ON local_media_repository(created_ts) WHERE url_cache IS NOT NULL;
-
--- we need to change `expires` to `expires_ts` so that we can index on it. SQLite doesn't support
--- indices on expressions until 3.9.
-CREATE TABLE local_media_repository_url_cache_new(
-    url TEXT,
-    response_code INTEGER,
-    etag TEXT,
-    expires_ts BIGINT,
-    og TEXT,
-    media_id TEXT,
-    download_ts BIGINT
-);
-
-INSERT INTO local_media_repository_url_cache_new
-    SELECT url, response_code, etag, expires + download_ts, og, media_id, download_ts FROM local_media_repository_url_cache;
-
-DROP TABLE local_media_repository_url_cache;
-ALTER TABLE local_media_repository_url_cache_new RENAME TO local_media_repository_url_cache;
-
-CREATE INDEX local_media_repository_url_cache_expires_idx ON local_media_repository_url_cache(expires_ts);
-CREATE INDEX local_media_repository_url_cache_by_url_download_ts ON local_media_repository_url_cache(url, download_ts);
-CREATE INDEX local_media_repository_url_cache_media_idx ON local_media_repository_url_cache(media_id);
diff --git a/synapse/storage/schema/delta/45/group_server.sql b/synapse/storage/schema/delta/45/group_server.sql
deleted file mode 100644
index b2333848a0..0000000000
--- a/synapse/storage/schema/delta/45/group_server.sql
+++ /dev/null
@@ -1,167 +0,0 @@
-/* Copyright 2017 Vector Creations Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-CREATE TABLE groups (
-    group_id TEXT NOT NULL,
-    name TEXT,  -- the display name of the room
-    avatar_url TEXT,
-    short_description TEXT,
-    long_description TEXT
-);
-
-CREATE UNIQUE INDEX groups_idx ON groups(group_id);
-
-
--- list of users the group server thinks are joined
-CREATE TABLE group_users (
-    group_id TEXT NOT NULL,
-    user_id TEXT NOT NULL,
-    is_admin BOOLEAN NOT NULL,
-    is_public BOOLEAN NOT NULL  -- whether the users membership can be seen by everyone
-);
-
-
-CREATE INDEX groups_users_g_idx ON group_users(group_id, user_id);
-CREATE INDEX groups_users_u_idx ON group_users(user_id);
-
--- list of users the group server thinks are invited
-CREATE TABLE group_invites (
-    group_id TEXT NOT NULL,
-    user_id TEXT NOT NULL
-);
-
-CREATE INDEX groups_invites_g_idx ON group_invites(group_id, user_id);
-CREATE INDEX groups_invites_u_idx ON group_invites(user_id);
-
-
-CREATE TABLE group_rooms (
-    group_id TEXT NOT NULL,
-    room_id TEXT NOT NULL,
-    is_public BOOLEAN NOT NULL  -- whether the room can be seen by everyone
-);
-
-CREATE UNIQUE INDEX groups_rooms_g_idx ON group_rooms(group_id, room_id);
-CREATE INDEX groups_rooms_r_idx ON group_rooms(room_id);
-
-
--- Rooms to include in the summary
-CREATE TABLE group_summary_rooms (
-    group_id TEXT NOT NULL,
-    room_id TEXT NOT NULL,
-    category_id TEXT NOT NULL,
-    room_order BIGINT NOT NULL,
-    is_public BOOLEAN NOT NULL, -- whether the room should be show to everyone
-    UNIQUE (group_id, category_id, room_id, room_order),
-    CHECK (room_order > 0)
-);
-
-CREATE UNIQUE INDEX group_summary_rooms_g_idx ON group_summary_rooms(group_id, room_id, category_id);
-
-
--- Categories to include in the summary
-CREATE TABLE group_summary_room_categories (
-    group_id TEXT NOT NULL,
-    category_id TEXT NOT NULL,
-    cat_order BIGINT NOT NULL,
-    UNIQUE (group_id, category_id, cat_order),
-    CHECK (cat_order > 0)
-);
-
--- The categories in the group
-CREATE TABLE group_room_categories (
-    group_id TEXT NOT NULL,
-    category_id TEXT NOT NULL,
-    profile TEXT NOT NULL,
-    is_public BOOLEAN NOT NULL, -- whether the category should be show to everyone
-    UNIQUE (group_id, category_id)
-);
-
--- The users to include in the group summary
-CREATE TABLE group_summary_users (
-    group_id TEXT NOT NULL,
-    user_id TEXT NOT NULL,
-    role_id TEXT NOT NULL,
-    user_order BIGINT NOT NULL,
-    is_public BOOLEAN NOT NULL  -- whether the user should be show to everyone
-);
-
-CREATE INDEX group_summary_users_g_idx ON group_summary_users(group_id);
-
--- The roles to include in the group summary
-CREATE TABLE group_summary_roles (
-    group_id TEXT NOT NULL,
-    role_id TEXT NOT NULL,
-    role_order BIGINT NOT NULL,
-    UNIQUE (group_id, role_id, role_order),
-    CHECK (role_order > 0)
-);
-
-
--- The roles in a groups
-CREATE TABLE group_roles (
-    group_id TEXT NOT NULL,
-    role_id TEXT NOT NULL,
-    profile TEXT NOT NULL,
-    is_public BOOLEAN NOT NULL,  -- whether the role should be show to everyone
-    UNIQUE (group_id, role_id)
-);
-
-
--- List of  attestations we've given out and need to renew
-CREATE TABLE group_attestations_renewals (
-    group_id TEXT NOT NULL,
-    user_id TEXT NOT NULL,
-    valid_until_ms BIGINT NOT NULL
-);
-
-CREATE INDEX group_attestations_renewals_g_idx ON group_attestations_renewals(group_id, user_id);
-CREATE INDEX group_attestations_renewals_u_idx ON group_attestations_renewals(user_id);
-CREATE INDEX group_attestations_renewals_v_idx ON group_attestations_renewals(valid_until_ms);
-
-
--- List of attestations we've received from remotes and are interested in.
-CREATE TABLE group_attestations_remote (
-    group_id TEXT NOT NULL,
-    user_id TEXT NOT NULL,
-    valid_until_ms BIGINT NOT NULL,
-    attestation_json TEXT NOT NULL
-);
-
-CREATE INDEX group_attestations_remote_g_idx ON group_attestations_remote(group_id, user_id);
-CREATE INDEX group_attestations_remote_u_idx ON group_attestations_remote(user_id);
-CREATE INDEX group_attestations_remote_v_idx ON group_attestations_remote(valid_until_ms);
-
-
--- The group membership for the HS's users
-CREATE TABLE local_group_membership (
-    group_id TEXT NOT NULL,
-    user_id TEXT NOT NULL,
-    is_admin BOOLEAN NOT NULL,
-    membership TEXT NOT NULL,
-    is_publicised BOOLEAN NOT NULL,  -- if the user is publicising their membership
-    content TEXT NOT NULL
-);
-
-CREATE INDEX local_group_membership_u_idx ON local_group_membership(user_id, group_id);
-CREATE INDEX local_group_membership_g_idx ON local_group_membership(group_id);
-
-
-CREATE TABLE local_group_updates (
-    stream_id BIGINT NOT NULL,
-    group_id TEXT NOT NULL,
-    user_id TEXT NOT NULL,
-    type TEXT NOT NULL,
-    content TEXT NOT NULL
-);
diff --git a/synapse/storage/schema/delta/45/profile_cache.sql b/synapse/storage/schema/delta/45/profile_cache.sql
deleted file mode 100644
index e5ddc84df0..0000000000
--- a/synapse/storage/schema/delta/45/profile_cache.sql
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Copyright 2017 New Vector Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
--- A subset of remote users whose profiles we have cached.
--- Whether a user is in this table or not is defined by the storage function
--- `is_subscribed_remote_profile_for_user`
-CREATE TABLE remote_profile_cache (
-    user_id TEXT NOT NULL,
-    displayname TEXT,
-    avatar_url TEXT,
-    last_check BIGINT NOT NULL
-);
-
-CREATE UNIQUE INDEX remote_profile_cache_user_id ON remote_profile_cache(user_id);
-CREATE INDEX remote_profile_cache_time ON remote_profile_cache(last_check);
diff --git a/synapse/storage/schema/delta/46/drop_refresh_tokens.sql b/synapse/storage/schema/delta/46/drop_refresh_tokens.sql
deleted file mode 100644
index 68c48a89a9..0000000000
--- a/synapse/storage/schema/delta/46/drop_refresh_tokens.sql
+++ /dev/null
@@ -1,17 +0,0 @@
-/* Copyright 2017 New Vector Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* we no longer use (or create) the refresh_tokens table */
-DROP TABLE IF EXISTS refresh_tokens;
diff --git a/synapse/storage/schema/delta/46/drop_unique_deleted_pushers.sql b/synapse/storage/schema/delta/46/drop_unique_deleted_pushers.sql
deleted file mode 100644
index bb307889c1..0000000000
--- a/synapse/storage/schema/delta/46/drop_unique_deleted_pushers.sql
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Copyright 2017 New Vector Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
--- drop the unique constraint on deleted_pushers so that we can just insert
--- into it rather than upserting.
-
-CREATE TABLE deleted_pushers2 (
-    stream_id BIGINT NOT NULL,
-    app_id TEXT NOT NULL,
-    pushkey TEXT NOT NULL,
-    user_id TEXT NOT NULL
-);
-
-INSERT INTO deleted_pushers2 (stream_id, app_id, pushkey, user_id)
-    SELECT stream_id, app_id, pushkey, user_id from deleted_pushers;
-
-DROP TABLE deleted_pushers;
-ALTER TABLE deleted_pushers2 RENAME TO deleted_pushers;
-
--- create the index after doing the inserts because that's more efficient.
--- it also means we can give it the same name as the old one without renaming.
-CREATE INDEX deleted_pushers_stream_id ON deleted_pushers (stream_id);
-
diff --git a/synapse/storage/schema/delta/46/group_server.sql b/synapse/storage/schema/delta/46/group_server.sql
deleted file mode 100644
index 097679bc9a..0000000000
--- a/synapse/storage/schema/delta/46/group_server.sql
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright 2017 New Vector Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-CREATE TABLE groups_new (
-    group_id TEXT NOT NULL,
-    name TEXT,  -- the display name of the room
-    avatar_url TEXT,
-    short_description TEXT,
-    long_description TEXT,
-    is_public BOOL NOT NULL -- whether non-members can access group APIs
-);
-
--- NB: awful hack to get the default to be true on postgres and 1 on sqlite
-INSERT INTO groups_new
-    SELECT group_id, name, avatar_url, short_description, long_description, (1=1) FROM groups;
-
-DROP TABLE groups;
-ALTER TABLE groups_new RENAME TO groups;
-
-CREATE UNIQUE INDEX groups_idx ON groups(group_id);
diff --git a/synapse/storage/schema/delta/46/local_media_repository_url_idx.sql b/synapse/storage/schema/delta/46/local_media_repository_url_idx.sql
deleted file mode 100644
index bbfc7f5d1a..0000000000
--- a/synapse/storage/schema/delta/46/local_media_repository_url_idx.sql
+++ /dev/null
@@ -1,24 +0,0 @@
-/* Copyright 2017 New Vector Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
--- register a background update which will recreate the
--- local_media_repository_url_idx index.
---
--- We do this as a bg update not because it is a particularly onerous
--- operation, but because we'd like it to be a partial index if possible, and
--- the background_index_update code will understand whether we are on
--- postgres or sqlite and behave accordingly.
-INSERT INTO background_updates (update_name, progress_json) VALUES
-    ('local_media_repository_url_idx', '{}');
diff --git a/synapse/storage/schema/delta/46/user_dir_null_room_ids.sql b/synapse/storage/schema/delta/46/user_dir_null_room_ids.sql
deleted file mode 100644
index cb0d5a2576..0000000000
--- a/synapse/storage/schema/delta/46/user_dir_null_room_ids.sql
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Copyright 2017 New Vector Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
--- change the user_directory table to also cover global local user profiles
--- rather than just profiles within specific rooms.
-
-CREATE TABLE user_directory2 (
-    user_id TEXT NOT NULL,
-    room_id TEXT,
-    display_name TEXT,
-    avatar_url TEXT
-);
-
-INSERT INTO user_directory2(user_id, room_id, display_name, avatar_url)
-    SELECT user_id, room_id, display_name, avatar_url from user_directory;
-
-DROP TABLE user_directory;
-ALTER TABLE user_directory2 RENAME TO user_directory;
-
--- create indexes after doing the inserts because that's more efficient.
--- it also means we can give it the same name as the old one without renaming.
-CREATE INDEX user_directory_room_idx ON user_directory(room_id);
-CREATE UNIQUE INDEX user_directory_user_idx ON user_directory(user_id);
diff --git a/synapse/storage/schema/delta/46/user_dir_typos.sql b/synapse/storage/schema/delta/46/user_dir_typos.sql
deleted file mode 100644
index d9505f8da1..0000000000
--- a/synapse/storage/schema/delta/46/user_dir_typos.sql
+++ /dev/null
@@ -1,24 +0,0 @@
-/* Copyright 2017 New Vector Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
--- this is just embarassing :|
-ALTER TABLE users_in_pubic_room RENAME TO users_in_public_rooms;
-
--- this is only 300K rows on matrix.org and takes ~3s to generate the index,
--- so is hopefully not going to block anyone else for that long...
-CREATE INDEX users_in_public_rooms_room_idx ON users_in_public_rooms(room_id);
-CREATE UNIQUE INDEX users_in_public_rooms_user_idx ON users_in_public_rooms(user_id);
-DROP INDEX users_in_pubic_room_room_idx;
-DROP INDEX users_in_pubic_room_user_idx;
diff --git a/synapse/storage/schema/delta/47/last_access_media.sql b/synapse/storage/schema/delta/47/last_access_media.sql
deleted file mode 100644
index f505fb22b5..0000000000
--- a/synapse/storage/schema/delta/47/last_access_media.sql
+++ /dev/null
@@ -1,16 +0,0 @@
-/* Copyright 2018 New Vector Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-ALTER TABLE local_media_repository ADD COLUMN last_access_ts BIGINT;
diff --git a/synapse/storage/schema/delta/47/postgres_fts_gin.sql b/synapse/storage/schema/delta/47/postgres_fts_gin.sql
deleted file mode 100644
index 31d7a817eb..0000000000
--- a/synapse/storage/schema/delta/47/postgres_fts_gin.sql
+++ /dev/null
@@ -1,17 +0,0 @@
-/* Copyright 2018 New Vector Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-INSERT into background_updates (update_name, progress_json)
-    VALUES ('event_search_postgres_gin', '{}');
diff --git a/synapse/storage/schema/delta/47/push_actions_staging.sql b/synapse/storage/schema/delta/47/push_actions_staging.sql
deleted file mode 100644
index edccf4a96f..0000000000
--- a/synapse/storage/schema/delta/47/push_actions_staging.sql
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Copyright 2018 New Vector Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
--- Temporary staging area for push actions that have been calculated for an
--- event, but the event hasn't yet been persisted.
--- When the event is persisted the rows are moved over to the
--- event_push_actions table.
-CREATE TABLE event_push_actions_staging (
-    event_id TEXT NOT NULL,
-    user_id TEXT NOT NULL,
-    actions TEXT NOT NULL,
-    notif SMALLINT NOT NULL,
-    highlight SMALLINT NOT NULL
-);
-
-CREATE INDEX event_push_actions_staging_id ON event_push_actions_staging(event_id);
diff --git a/synapse/storage/schema/delta/47/state_group_seq.py b/synapse/storage/schema/delta/47/state_group_seq.py
deleted file mode 100644
index 9fd1ccf6f7..0000000000
--- a/synapse/storage/schema/delta/47/state_group_seq.py
+++ /dev/null
@@ -1,34 +0,0 @@
-# Copyright 2018 New Vector Ltd
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from synapse.storage.engines import PostgresEngine
-
-
-def run_create(cur, database_engine, *args, **kwargs):
-    if isinstance(database_engine, PostgresEngine):
-        # if we already have some state groups, we want to start making new
-        # ones with a higher id.
-        cur.execute("SELECT max(id) FROM state_groups")
-        row = cur.fetchone()
-
-        if row[0] is None:
-            start_val = 1
-        else:
-            start_val = row[0] + 1
-
-        cur.execute("CREATE SEQUENCE state_group_id_seq START WITH %s", (start_val,))
-
-
-def run_upgrade(*args, **kwargs):
-    pass
diff --git a/synapse/storage/schema/delta/48/add_user_consent.sql b/synapse/storage/schema/delta/48/add_user_consent.sql
deleted file mode 100644
index 5237491506..0000000000
--- a/synapse/storage/schema/delta/48/add_user_consent.sql
+++ /dev/null
@@ -1,18 +0,0 @@
-/* Copyright 2018 New Vector Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* record the version of the privacy policy the user has consented to
- */
-ALTER TABLE users ADD COLUMN consent_version TEXT;
diff --git a/synapse/storage/schema/delta/48/add_user_ips_last_seen_index.sql b/synapse/storage/schema/delta/48/add_user_ips_last_seen_index.sql
deleted file mode 100644
index 9248b0b24a..0000000000
--- a/synapse/storage/schema/delta/48/add_user_ips_last_seen_index.sql
+++ /dev/null
@@ -1,17 +0,0 @@
-/* Copyright 2018 New Vector Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-INSERT into background_updates (update_name, progress_json)
-    VALUES ('user_ips_last_seen_index', '{}');
diff --git a/synapse/storage/schema/delta/48/deactivated_users.sql b/synapse/storage/schema/delta/48/deactivated_users.sql
deleted file mode 100644
index e9013a6969..0000000000
--- a/synapse/storage/schema/delta/48/deactivated_users.sql
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Copyright 2018 New Vector Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * Store any accounts that have been requested to be deactivated.
- * We part the account from all the rooms its in when its
- * deactivated. This can take some time and synapse may be restarted
- * before it completes, so store the user IDs here until the process
- * is complete.
- */
-CREATE TABLE users_pending_deactivation (
-    user_id TEXT NOT NULL
-);
diff --git a/synapse/storage/schema/delta/48/group_unique_indexes.py b/synapse/storage/schema/delta/48/group_unique_indexes.py
deleted file mode 100644
index 49f5f2c003..0000000000
--- a/synapse/storage/schema/delta/48/group_unique_indexes.py
+++ /dev/null
@@ -1,63 +0,0 @@
-# Copyright 2018 New Vector Ltd
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from synapse.storage.engines import PostgresEngine
-from synapse.storage.prepare_database import get_statements
-
-FIX_INDEXES = """
--- rebuild indexes as uniques
-DROP INDEX groups_invites_g_idx;
-CREATE UNIQUE INDEX group_invites_g_idx ON group_invites(group_id, user_id);
-DROP INDEX groups_users_g_idx;
-CREATE UNIQUE INDEX group_users_g_idx ON group_users(group_id, user_id);
-
--- rename other indexes to actually match their table names..
-DROP INDEX groups_users_u_idx;
-CREATE INDEX group_users_u_idx ON group_users(user_id);
-DROP INDEX groups_invites_u_idx;
-CREATE INDEX group_invites_u_idx ON group_invites(user_id);
-DROP INDEX groups_rooms_g_idx;
-CREATE UNIQUE INDEX group_rooms_g_idx ON group_rooms(group_id, room_id);
-DROP INDEX groups_rooms_r_idx;
-CREATE INDEX group_rooms_r_idx ON group_rooms(room_id);
-"""
-
-
-def run_create(cur, database_engine, *args, **kwargs):
-    rowid = "ctid" if isinstance(database_engine, PostgresEngine) else "rowid"
-
-    # remove duplicates from group_users & group_invites tables
-    cur.execute(
-        """
-        DELETE FROM group_users WHERE %s NOT IN (
-           SELECT min(%s) FROM group_users GROUP BY group_id, user_id
-        );
-    """
-        % (rowid, rowid)
-    )
-    cur.execute(
-        """
-        DELETE FROM group_invites WHERE %s NOT IN (
-           SELECT min(%s) FROM group_invites GROUP BY group_id, user_id
-        );
-    """
-        % (rowid, rowid)
-    )
-
-    for statement in get_statements(FIX_INDEXES.splitlines()):
-        cur.execute(statement)
-
-
-def run_upgrade(*args, **kwargs):
-    pass
diff --git a/synapse/storage/schema/delta/48/groups_joinable.sql b/synapse/storage/schema/delta/48/groups_joinable.sql
deleted file mode 100644
index ce26eaf0c9..0000000000
--- a/synapse/storage/schema/delta/48/groups_joinable.sql
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Copyright 2018 New Vector Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* 
- * This isn't a real ENUM because sqlite doesn't support it
- * and we use a default of NULL for inserted rows and interpret
- * NULL at the python store level as necessary so that existing
- * rows are given the correct default policy.
- */
-ALTER TABLE groups ADD COLUMN join_policy TEXT NOT NULL DEFAULT 'invite';
diff --git a/synapse/storage/schema/delta/49/add_user_consent_server_notice_sent.sql b/synapse/storage/schema/delta/49/add_user_consent_server_notice_sent.sql
deleted file mode 100644
index 14dcf18d73..0000000000
--- a/synapse/storage/schema/delta/49/add_user_consent_server_notice_sent.sql
+++ /dev/null
@@ -1,20 +0,0 @@
-/* Copyright 2018 New Vector Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* record whether we have sent a server notice about consenting to the
- * privacy policy. Specifically records the version of the policy we sent
- * a message about.
- */
-ALTER TABLE users ADD COLUMN consent_server_notice_sent TEXT;
diff --git a/synapse/storage/schema/delta/49/add_user_daily_visits.sql b/synapse/storage/schema/delta/49/add_user_daily_visits.sql
deleted file mode 100644
index 3dd478196f..0000000000
--- a/synapse/storage/schema/delta/49/add_user_daily_visits.sql
+++ /dev/null
@@ -1,21 +0,0 @@
-/* Copyright 2018 New Vector Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-CREATE TABLE user_daily_visits ( user_id TEXT NOT NULL,
-                                 device_id TEXT,
-                                 timestamp BIGINT NOT NULL );
-CREATE INDEX user_daily_visits_uts_idx ON user_daily_visits(user_id, timestamp);
-CREATE INDEX user_daily_visits_ts_idx ON user_daily_visits(timestamp);
diff --git a/synapse/storage/schema/delta/49/add_user_ips_last_seen_only_index.sql b/synapse/storage/schema/delta/49/add_user_ips_last_seen_only_index.sql
deleted file mode 100644
index 3a4ed59b5b..0000000000
--- a/synapse/storage/schema/delta/49/add_user_ips_last_seen_only_index.sql
+++ /dev/null
@@ -1,17 +0,0 @@
-/* Copyright 2018 New Vector Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-INSERT into background_updates (update_name, progress_json)
-    VALUES ('user_ips_last_seen_only_index', '{}');
diff --git a/synapse/storage/schema/delta/50/add_creation_ts_users_index.sql b/synapse/storage/schema/delta/50/add_creation_ts_users_index.sql
deleted file mode 100644
index c93ae47532..0000000000
--- a/synapse/storage/schema/delta/50/add_creation_ts_users_index.sql
+++ /dev/null
@@ -1,19 +0,0 @@
-/* Copyright 2018 New Vector Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-
-INSERT into background_updates (update_name, progress_json)
-    VALUES ('users_creation_ts', '{}');
diff --git a/synapse/storage/schema/delta/50/erasure_store.sql b/synapse/storage/schema/delta/50/erasure_store.sql
deleted file mode 100644
index 5d8641a9ab..0000000000
--- a/synapse/storage/schema/delta/50/erasure_store.sql
+++ /dev/null
@@ -1,21 +0,0 @@
-/* Copyright 2018 New Vector Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
--- a table of users who have requested that their details be erased
-CREATE TABLE erased_users (
-    user_id TEXT NOT NULL
-);
-
-CREATE UNIQUE INDEX erased_users_user ON erased_users(user_id);
diff --git a/synapse/storage/schema/delta/50/make_event_content_nullable.py b/synapse/storage/schema/delta/50/make_event_content_nullable.py
deleted file mode 100644
index b1684a8441..0000000000
--- a/synapse/storage/schema/delta/50/make_event_content_nullable.py
+++ /dev/null
@@ -1,96 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2018 New Vector Ltd
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""
-We want to stop populating 'event.content', so we need to make it nullable.
-
-If this has to be rolled back, then the following should populate the missing data:
-
-Postgres:
-
-    UPDATE events SET content=(ej.json::json)->'content' FROM event_json ej
-    WHERE ej.event_id = events.event_id AND
-        stream_ordering < (
-            SELECT stream_ordering FROM events WHERE content IS NOT NULL
-            ORDER BY stream_ordering LIMIT 1
-        );
-
-    UPDATE events SET content=(ej.json::json)->'content' FROM event_json ej
-    WHERE ej.event_id = events.event_id AND
-        stream_ordering > (
-            SELECT stream_ordering FROM events WHERE content IS NOT NULL
-            ORDER BY stream_ordering DESC LIMIT 1
-        );
-
-SQLite:
-
-    UPDATE events SET content=(
-        SELECT json_extract(json,'$.content') FROM event_json ej
-        WHERE ej.event_id = events.event_id
-    )
-    WHERE
-        stream_ordering < (
-            SELECT stream_ordering FROM events WHERE content IS NOT NULL
-            ORDER BY stream_ordering LIMIT 1
-        )
-        OR stream_ordering > (
-            SELECT stream_ordering FROM events WHERE content IS NOT NULL
-            ORDER BY stream_ordering DESC LIMIT 1
-        );
-
-"""
-
-import logging
-
-from synapse.storage.engines import PostgresEngine
-
-logger = logging.getLogger(__name__)
-
-
-def run_create(cur, database_engine, *args, **kwargs):
-    pass
-
-
-def run_upgrade(cur, database_engine, *args, **kwargs):
-    if isinstance(database_engine, PostgresEngine):
-        cur.execute(
-            """
-            ALTER TABLE events ALTER COLUMN content DROP NOT NULL;
-        """
-        )
-        return
-
-    # sqlite is an arse about this. ref: https://www.sqlite.org/lang_altertable.html
-
-    cur.execute(
-        "SELECT sql FROM sqlite_master WHERE tbl_name='events' AND type='table'"
-    )
-    (oldsql,) = cur.fetchone()
-
-    sql = oldsql.replace("content TEXT NOT NULL", "content TEXT")
-    if sql == oldsql:
-        raise Exception("Couldn't find null constraint to drop in %s" % oldsql)
-
-    logger.info("Replacing definition of 'events' with: %s", sql)
-
-    cur.execute("PRAGMA schema_version")
-    (oldver,) = cur.fetchone()
-    cur.execute("PRAGMA writable_schema=ON")
-    cur.execute(
-        "UPDATE sqlite_master SET sql=? WHERE tbl_name='events' AND type='table'",
-        (sql,),
-    )
-    cur.execute("PRAGMA schema_version=%i" % (oldver + 1,))
-    cur.execute("PRAGMA writable_schema=OFF")
diff --git a/synapse/storage/schema/delta/51/e2e_room_keys.sql b/synapse/storage/schema/delta/51/e2e_room_keys.sql
deleted file mode 100644
index c0e66a697d..0000000000
--- a/synapse/storage/schema/delta/51/e2e_room_keys.sql
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Copyright 2017 New Vector Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
--- users' optionally backed up encrypted e2e sessions
-CREATE TABLE e2e_room_keys (
-    user_id TEXT NOT NULL,
-    room_id TEXT NOT NULL,
-    session_id TEXT NOT NULL,
-    version TEXT NOT NULL,
-    first_message_index INT,
-    forwarded_count INT,
-    is_verified BOOLEAN,
-    session_data TEXT NOT NULL
-);
-
-CREATE UNIQUE INDEX e2e_room_keys_idx ON e2e_room_keys(user_id, room_id, session_id);
-
--- the metadata for each generation of encrypted e2e session backups
-CREATE TABLE e2e_room_keys_versions (
-    user_id TEXT NOT NULL,
-    version TEXT NOT NULL,
-    algorithm TEXT NOT NULL,
-    auth_data TEXT NOT NULL,
-    deleted SMALLINT DEFAULT 0 NOT NULL
-);
-
-CREATE UNIQUE INDEX e2e_room_keys_versions_idx ON e2e_room_keys_versions(user_id, version);
diff --git a/synapse/storage/schema/delta/51/monthly_active_users.sql b/synapse/storage/schema/delta/51/monthly_active_users.sql
deleted file mode 100644
index c9d537d5a3..0000000000
--- a/synapse/storage/schema/delta/51/monthly_active_users.sql
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Copyright 2018 New Vector Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
--- a table of monthly active users, for use where blocking based on mau limits
-CREATE TABLE monthly_active_users (
-    user_id TEXT NOT NULL,
-    -- Last time we saw the user. Not guaranteed to be accurate due to rate limiting
-    -- on updates, Granularity of updates governed by
-    -- synapse.storage.monthly_active_users.LAST_SEEN_GRANULARITY
-    -- Measured in ms since epoch.
-    timestamp BIGINT NOT NULL
-);
-
-CREATE UNIQUE INDEX monthly_active_users_users ON monthly_active_users(user_id);
-CREATE INDEX monthly_active_users_time_stamp ON monthly_active_users(timestamp);
diff --git a/synapse/storage/schema/delta/52/add_event_to_state_group_index.sql b/synapse/storage/schema/delta/52/add_event_to_state_group_index.sql
deleted file mode 100644
index 91e03d13e1..0000000000
--- a/synapse/storage/schema/delta/52/add_event_to_state_group_index.sql
+++ /dev/null
@@ -1,19 +0,0 @@
-/* Copyright 2018 New Vector Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
--- This is needed to efficiently check for unreferenced state groups during
--- purge. Added events_to_state_group(state_group) index
-INSERT into background_updates (update_name, progress_json)
-    VALUES ('event_to_state_groups_sg_index', '{}');
diff --git a/synapse/storage/schema/delta/52/device_list_streams_unique_idx.sql b/synapse/storage/schema/delta/52/device_list_streams_unique_idx.sql
deleted file mode 100644
index bfa49e6f92..0000000000
--- a/synapse/storage/schema/delta/52/device_list_streams_unique_idx.sql
+++ /dev/null
@@ -1,36 +0,0 @@
-/* Copyright 2018 New Vector Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
--- register a background update which will create a unique index on
--- device_lists_remote_cache
-INSERT into background_updates (update_name, progress_json)
-    VALUES ('device_lists_remote_cache_unique_idx', '{}');
-
--- and one on device_lists_remote_extremeties
-INSERT into background_updates (update_name, progress_json, depends_on)
-    VALUES (
-        'device_lists_remote_extremeties_unique_idx', '{}',
-
-        -- doesn't really depend on this, but we need to make sure both happen
-        -- before we drop the old indexes.
-        'device_lists_remote_cache_unique_idx'
-    );
-
--- once they complete, we can drop the old indexes.
-INSERT into background_updates (update_name, progress_json, depends_on)
-    VALUES (
-        'drop_device_list_streams_non_unique_indexes', '{}',
-        'device_lists_remote_extremeties_unique_idx'
-    );
diff --git a/synapse/storage/schema/delta/52/e2e_room_keys.sql b/synapse/storage/schema/delta/52/e2e_room_keys.sql
deleted file mode 100644
index db687cccae..0000000000
--- a/synapse/storage/schema/delta/52/e2e_room_keys.sql
+++ /dev/null
@@ -1,53 +0,0 @@
-/* Copyright 2018 New Vector Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* Change version column to an integer so we can do MAX() sensibly
- */
-CREATE TABLE e2e_room_keys_versions_new (
-    user_id TEXT NOT NULL,
-    version BIGINT NOT NULL,
-    algorithm TEXT NOT NULL,
-    auth_data TEXT NOT NULL,
-    deleted SMALLINT DEFAULT 0 NOT NULL
-);
-
-INSERT INTO e2e_room_keys_versions_new
-    SELECT user_id, CAST(version as BIGINT), algorithm, auth_data, deleted FROM e2e_room_keys_versions;
-
-DROP TABLE e2e_room_keys_versions;
-ALTER TABLE e2e_room_keys_versions_new RENAME TO e2e_room_keys_versions;
-
-CREATE UNIQUE INDEX e2e_room_keys_versions_idx ON e2e_room_keys_versions(user_id, version);
-
-/* Change e2e_rooms_keys to match
- */
-CREATE TABLE e2e_room_keys_new (
-    user_id TEXT NOT NULL,
-    room_id TEXT NOT NULL,
-    session_id TEXT NOT NULL,
-    version BIGINT NOT NULL,
-    first_message_index INT,
-    forwarded_count INT,
-    is_verified BOOLEAN,
-    session_data TEXT NOT NULL
-);
-
-INSERT INTO e2e_room_keys_new
-    SELECT user_id, room_id, session_id, CAST(version as BIGINT), first_message_index, forwarded_count, is_verified, session_data FROM e2e_room_keys;
-
-DROP TABLE e2e_room_keys;
-ALTER TABLE e2e_room_keys_new RENAME TO e2e_room_keys;
-
-CREATE UNIQUE INDEX e2e_room_keys_idx ON e2e_room_keys(user_id, room_id, session_id);
diff --git a/synapse/storage/schema/delta/53/add_user_type_to_users.sql b/synapse/storage/schema/delta/53/add_user_type_to_users.sql
deleted file mode 100644
index 88ec2f83e5..0000000000
--- a/synapse/storage/schema/delta/53/add_user_type_to_users.sql
+++ /dev/null
@@ -1,19 +0,0 @@
-/* Copyright 2018 New Vector Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* The type of the user: NULL for a regular user, or one of the constants in 
- * synapse.api.constants.UserTypes
- */
-ALTER TABLE users ADD COLUMN user_type TEXT DEFAULT NULL;
diff --git a/synapse/storage/schema/delta/53/drop_sent_transactions.sql b/synapse/storage/schema/delta/53/drop_sent_transactions.sql
deleted file mode 100644
index e372f5a44a..0000000000
--- a/synapse/storage/schema/delta/53/drop_sent_transactions.sql
+++ /dev/null
@@ -1,16 +0,0 @@
-/* Copyright 2018 New Vector Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-DROP TABLE IF EXISTS sent_transactions;
diff --git a/synapse/storage/schema/delta/53/event_format_version.sql b/synapse/storage/schema/delta/53/event_format_version.sql
deleted file mode 100644
index 1d977c2834..0000000000
--- a/synapse/storage/schema/delta/53/event_format_version.sql
+++ /dev/null
@@ -1,16 +0,0 @@
-/* Copyright 2019 New Vector Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-ALTER TABLE event_json ADD COLUMN format_version INTEGER;
diff --git a/synapse/storage/schema/delta/53/user_dir_populate.sql b/synapse/storage/schema/delta/53/user_dir_populate.sql
deleted file mode 100644
index ffcc896b58..0000000000
--- a/synapse/storage/schema/delta/53/user_dir_populate.sql
+++ /dev/null
@@ -1,30 +0,0 @@
-/* Copyright 2019 New Vector Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
--- Set up staging tables
-INSERT INTO background_updates (update_name, progress_json) VALUES
-    ('populate_user_directory_createtables', '{}');
-
--- Run through each room and update the user directory according to who is in it
-INSERT INTO background_updates (update_name, progress_json, depends_on) VALUES
-    ('populate_user_directory_process_rooms', '{}', 'populate_user_directory_createtables');
-
--- Insert all users, if search_all_users is on
-INSERT INTO background_updates (update_name, progress_json, depends_on) VALUES
-    ('populate_user_directory_process_users', '{}', 'populate_user_directory_process_rooms');
-
--- Clean up staging tables
-INSERT INTO background_updates (update_name, progress_json, depends_on) VALUES
-    ('populate_user_directory_cleanup', '{}', 'populate_user_directory_process_users');
diff --git a/synapse/storage/schema/delta/53/user_ips_index.sql b/synapse/storage/schema/delta/53/user_ips_index.sql
deleted file mode 100644
index b812c5794f..0000000000
--- a/synapse/storage/schema/delta/53/user_ips_index.sql
+++ /dev/null
@@ -1,30 +0,0 @@
-/* Copyright 2018 New Vector Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
- -- analyze user_ips, to help ensure the correct indices are used
-INSERT INTO background_updates (update_name, progress_json) VALUES
-  ('user_ips_analyze', '{}');
-
--- delete duplicates
-INSERT INTO background_updates (update_name, progress_json, depends_on) VALUES
-  ('user_ips_remove_dupes', '{}', 'user_ips_analyze');
-
--- add a new unique index to user_ips table
-INSERT INTO background_updates (update_name, progress_json, depends_on) VALUES
-  ('user_ips_device_unique_index', '{}', 'user_ips_remove_dupes');
-
--- drop the old original index
-INSERT INTO background_updates (update_name, progress_json, depends_on) VALUES
-  ('user_ips_drop_nonunique_index', '{}', 'user_ips_device_unique_index');
diff --git a/synapse/storage/schema/delta/53/user_share.sql b/synapse/storage/schema/delta/53/user_share.sql
deleted file mode 100644
index 5831b1a6f8..0000000000
--- a/synapse/storage/schema/delta/53/user_share.sql
+++ /dev/null
@@ -1,44 +0,0 @@
-/* Copyright 2017 Vector Creations Ltd, 2019 New Vector Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
--- Old disused version of the tables below.
-DROP TABLE IF EXISTS users_who_share_rooms;
-
--- Tables keeping track of what users share rooms. This is a map of local users
--- to local or remote users, per room. Remote users cannot be in the user_id
--- column, only the other_user_id column. There are two tables, one for public
--- rooms and those for private rooms.
-CREATE TABLE IF NOT EXISTS users_who_share_public_rooms (
-    user_id TEXT NOT NULL,
-    other_user_id TEXT NOT NULL,
-    room_id TEXT NOT NULL
-);
-
-CREATE TABLE IF NOT EXISTS users_who_share_private_rooms (
-    user_id TEXT NOT NULL,
-    other_user_id TEXT NOT NULL,
-    room_id TEXT NOT NULL
-);
-
-CREATE UNIQUE INDEX users_who_share_public_rooms_u_idx ON users_who_share_public_rooms(user_id, other_user_id, room_id);
-CREATE INDEX users_who_share_public_rooms_r_idx ON users_who_share_public_rooms(room_id);
-CREATE INDEX users_who_share_public_rooms_o_idx ON users_who_share_public_rooms(other_user_id);
-
-CREATE UNIQUE INDEX users_who_share_private_rooms_u_idx ON users_who_share_private_rooms(user_id, other_user_id, room_id);
-CREATE INDEX users_who_share_private_rooms_r_idx ON users_who_share_private_rooms(room_id);
-CREATE INDEX users_who_share_private_rooms_o_idx ON users_who_share_private_rooms(other_user_id);
-
--- Make sure that we populate the tables initially by resetting the stream ID
-UPDATE user_directory_stream_pos SET stream_id = NULL;
diff --git a/synapse/storage/schema/delta/53/user_threepid_id.sql b/synapse/storage/schema/delta/53/user_threepid_id.sql
deleted file mode 100644
index 80c2c573b6..0000000000
--- a/synapse/storage/schema/delta/53/user_threepid_id.sql
+++ /dev/null
@@ -1,29 +0,0 @@
-/* Copyright 2019 New Vector Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
--- Tracks which identity server a user bound their threepid via.
-CREATE TABLE user_threepid_id_server (
-    user_id TEXT NOT NULL,
-    medium TEXT NOT NULL,
-    address TEXT NOT NULL,
-    id_server TEXT NOT NULL
-);
-
-CREATE UNIQUE INDEX user_threepid_id_server_idx ON user_threepid_id_server(
-    user_id, medium, address, id_server
-);
-
-INSERT INTO background_updates (update_name, progress_json) VALUES
-  ('user_threepids_grandfather', '{}');
diff --git a/synapse/storage/schema/delta/53/users_in_public_rooms.sql b/synapse/storage/schema/delta/53/users_in_public_rooms.sql
deleted file mode 100644
index f7827ca6d2..0000000000
--- a/synapse/storage/schema/delta/53/users_in_public_rooms.sql
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Copyright 2019 New Vector Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
--- We don't need the old version of this table.
-DROP TABLE IF EXISTS users_in_public_rooms;
-
--- Old version of users_in_public_rooms
-DROP TABLE IF EXISTS users_who_share_public_rooms;
-
--- Track what users are in public rooms.
-CREATE TABLE IF NOT EXISTS users_in_public_rooms (
-    user_id TEXT NOT NULL,
-    room_id TEXT NOT NULL
-);
-
-CREATE UNIQUE INDEX users_in_public_rooms_u_idx ON users_in_public_rooms(user_id, room_id);
diff --git a/synapse/storage/schema/delta/54/account_validity_with_renewal.sql b/synapse/storage/schema/delta/54/account_validity_with_renewal.sql
deleted file mode 100644
index 0adb2ad55e..0000000000
--- a/synapse/storage/schema/delta/54/account_validity_with_renewal.sql
+++ /dev/null
@@ -1,30 +0,0 @@
-/* Copyright 2019 New Vector Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
--- We previously changed the schema for this table without renaming the file, which means
--- that some databases might still be using the old schema. This ensures Synapse uses the
--- right schema for the table.
-DROP TABLE IF EXISTS account_validity;
-
--- Track what users are in public rooms.
-CREATE TABLE IF NOT EXISTS account_validity (
-    user_id TEXT PRIMARY KEY,
-    expiration_ts_ms BIGINT NOT NULL,
-    email_sent BOOLEAN NOT NULL,
-    renewal_token TEXT
-);
-
-CREATE INDEX account_validity_email_sent_idx ON account_validity(email_sent, expiration_ts_ms)
-CREATE UNIQUE INDEX account_validity_renewal_string_idx ON account_validity(renewal_token)
diff --git a/synapse/storage/schema/delta/54/add_validity_to_server_keys.sql b/synapse/storage/schema/delta/54/add_validity_to_server_keys.sql
deleted file mode 100644
index c01aa9d2d9..0000000000
--- a/synapse/storage/schema/delta/54/add_validity_to_server_keys.sql
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Copyright 2019 New Vector Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* When we can use this key until, before we have to refresh it. */
-ALTER TABLE server_signature_keys ADD COLUMN ts_valid_until_ms BIGINT;
-
-UPDATE server_signature_keys SET ts_valid_until_ms = (
-    SELECT MAX(ts_valid_until_ms) FROM server_keys_json skj WHERE
-        skj.server_name = server_signature_keys.server_name AND
-        skj.key_id = server_signature_keys.key_id
-);
diff --git a/synapse/storage/schema/delta/54/delete_forward_extremities.sql b/synapse/storage/schema/delta/54/delete_forward_extremities.sql
deleted file mode 100644
index b062ec840c..0000000000
--- a/synapse/storage/schema/delta/54/delete_forward_extremities.sql
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Copyright 2019 The Matrix.org Foundation C.I.C.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
--- Start a background job to cleanup extremities that were incorrectly added
--- by bug #5269.
-INSERT INTO background_updates (update_name, progress_json) VALUES
-  ('delete_soft_failed_extremities', '{}');
-
-DROP TABLE IF EXISTS _extremities_to_check;  -- To make this delta schema file idempotent.
-CREATE TABLE _extremities_to_check AS SELECT event_id FROM event_forward_extremities;
-CREATE INDEX _extremities_to_check_id ON _extremities_to_check(event_id);
diff --git a/synapse/storage/schema/delta/54/drop_legacy_tables.sql b/synapse/storage/schema/delta/54/drop_legacy_tables.sql
deleted file mode 100644
index dbbe682697..0000000000
--- a/synapse/storage/schema/delta/54/drop_legacy_tables.sql
+++ /dev/null
@@ -1,30 +0,0 @@
-/* Copyright 2019 New Vector Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
--- we need to do this first due to foreign constraints
-DROP TABLE IF EXISTS application_services_regex;
-
-DROP TABLE IF EXISTS application_services;
-DROP TABLE IF EXISTS transaction_id_to_pdu;
-DROP TABLE IF EXISTS stats_reporting;
-DROP TABLE IF EXISTS current_state_resets;
-DROP TABLE IF EXISTS event_content_hashes;
-DROP TABLE IF EXISTS event_destinations;
-DROP TABLE IF EXISTS event_edge_hashes;
-DROP TABLE IF EXISTS event_signatures;
-DROP TABLE IF EXISTS feedback;
-DROP TABLE IF EXISTS room_hosts;
-DROP TABLE IF EXISTS server_tls_certificates;
-DROP TABLE IF EXISTS state_forward_extremities;
diff --git a/synapse/storage/schema/delta/54/drop_presence_list.sql b/synapse/storage/schema/delta/54/drop_presence_list.sql
deleted file mode 100644
index e6ee70c623..0000000000
--- a/synapse/storage/schema/delta/54/drop_presence_list.sql
+++ /dev/null
@@ -1,16 +0,0 @@
-/* Copyright 2019 New Vector Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-DROP TABLE IF EXISTS presence_list;
diff --git a/synapse/storage/schema/delta/54/relations.sql b/synapse/storage/schema/delta/54/relations.sql
deleted file mode 100644
index 134862b870..0000000000
--- a/synapse/storage/schema/delta/54/relations.sql
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Copyright 2019 New Vector Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
--- Tracks related events, like reactions, replies, edits, etc. Note that things
--- in this table are not necessarily "valid", e.g. it may contain edits from
--- people who don't have power to edit other peoples events.
-CREATE TABLE IF NOT EXISTS event_relations (
-    event_id TEXT NOT NULL,
-    relates_to_id TEXT NOT NULL,
-    relation_type TEXT NOT NULL,
-    aggregation_key TEXT
-);
-
-CREATE UNIQUE INDEX event_relations_id ON event_relations(event_id);
-CREATE INDEX event_relations_relates ON event_relations(relates_to_id, relation_type, aggregation_key);
diff --git a/synapse/storage/schema/delta/54/stats.sql b/synapse/storage/schema/delta/54/stats.sql
deleted file mode 100644
index 652e58308e..0000000000
--- a/synapse/storage/schema/delta/54/stats.sql
+++ /dev/null
@@ -1,80 +0,0 @@
-/* Copyright 2018 New Vector Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-CREATE TABLE stats_stream_pos (
-    Lock CHAR(1) NOT NULL DEFAULT 'X' UNIQUE,  -- Makes sure this table only has one row.
-    stream_id BIGINT,
-    CHECK (Lock='X')
-);
-
-INSERT INTO stats_stream_pos (stream_id) VALUES (null);
-
-CREATE TABLE user_stats (
-    user_id TEXT NOT NULL,
-    ts BIGINT NOT NULL,
-    bucket_size INT NOT NULL,
-    public_rooms INT NOT NULL,
-    private_rooms INT NOT NULL
-);
-
-CREATE UNIQUE INDEX user_stats_user_ts ON user_stats(user_id, ts);
-
-CREATE TABLE room_stats (
-    room_id TEXT NOT NULL,
-    ts BIGINT NOT NULL,
-    bucket_size INT NOT NULL,
-    current_state_events INT NOT NULL,
-    joined_members INT NOT NULL,
-    invited_members INT NOT NULL,
-    left_members INT NOT NULL,
-    banned_members INT NOT NULL,
-    state_events INT NOT NULL
-);
-
-CREATE UNIQUE INDEX room_stats_room_ts ON room_stats(room_id, ts);
-
--- cache of current room state; useful for the publicRooms list
-CREATE TABLE room_state (
-    room_id TEXT NOT NULL,
-    join_rules TEXT,
-    history_visibility TEXT,
-    encryption TEXT,
-    name TEXT,
-    topic TEXT,
-    avatar TEXT,
-    canonical_alias TEXT
-    -- get aliases straight from the right table
-);
-
-CREATE UNIQUE INDEX room_state_room ON room_state(room_id);
-
-CREATE TABLE room_stats_earliest_token (
-    room_id TEXT NOT NULL,
-    token BIGINT NOT NULL
-);
-
-CREATE UNIQUE INDEX room_stats_earliest_token_idx ON room_stats_earliest_token(room_id);
-
--- Set up staging tables
-INSERT INTO background_updates (update_name, progress_json) VALUES
-    ('populate_stats_createtables', '{}');
-
--- Run through each room and update stats
-INSERT INTO background_updates (update_name, progress_json, depends_on) VALUES
-    ('populate_stats_process_rooms', '{}', 'populate_stats_createtables');
-
--- Clean up staging tables
-INSERT INTO background_updates (update_name, progress_json, depends_on) VALUES
-    ('populate_stats_cleanup', '{}', 'populate_stats_process_rooms');
diff --git a/synapse/storage/schema/delta/54/stats2.sql b/synapse/storage/schema/delta/54/stats2.sql
deleted file mode 100644
index 3b2d48447f..0000000000
--- a/synapse/storage/schema/delta/54/stats2.sql
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Copyright 2019 The Matrix.org Foundation C.I.C.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
--- This delta file gets run after `54/stats.sql` delta.
-
--- We want to add some indices to the temporary stats table, so we re-insert
--- 'populate_stats_createtables' if we are still processing the rooms update.
-INSERT INTO background_updates (update_name, progress_json)
-    SELECT 'populate_stats_createtables', '{}'
-    WHERE
-        'populate_stats_process_rooms' IN (
-            SELECT update_name FROM background_updates
-        )
-        AND 'populate_stats_createtables' NOT IN (  -- don't insert if already exists
-            SELECT update_name FROM background_updates
-        );
diff --git a/synapse/storage/schema/delta/55/access_token_expiry.sql b/synapse/storage/schema/delta/55/access_token_expiry.sql
deleted file mode 100644
index 4590604bfd..0000000000
--- a/synapse/storage/schema/delta/55/access_token_expiry.sql
+++ /dev/null
@@ -1,18 +0,0 @@
-/* Copyright 2019 The Matrix.org Foundation C.I.C.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
--- when this access token can be used until, in ms since the epoch. NULL means the token
--- never expires.
-ALTER TABLE access_tokens ADD COLUMN valid_until_ms BIGINT;
diff --git a/synapse/storage/schema/delta/55/track_threepid_validations.sql b/synapse/storage/schema/delta/55/track_threepid_validations.sql
deleted file mode 100644
index a8eced2e0a..0000000000
--- a/synapse/storage/schema/delta/55/track_threepid_validations.sql
+++ /dev/null
@@ -1,31 +0,0 @@
-/* Copyright 2019 The Matrix.org Foundation C.I.C.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-CREATE TABLE IF NOT EXISTS threepid_validation_session (
-    session_id TEXT PRIMARY KEY,
-    medium TEXT NOT NULL,
-    address TEXT NOT NULL,
-    client_secret TEXT NOT NULL,
-    last_send_attempt BIGINT NOT NULL,
-    validated_at BIGINT
-);
-
-CREATE TABLE IF NOT EXISTS threepid_validation_token (
-    token TEXT PRIMARY KEY,
-    session_id TEXT NOT NULL,
-    next_link TEXT,
-    expires BIGINT NOT NULL
-);
-
-CREATE INDEX threepid_validation_token_session_id ON threepid_validation_token(session_id);
diff --git a/synapse/storage/schema/delta/55/users_alter_deactivated.sql b/synapse/storage/schema/delta/55/users_alter_deactivated.sql
deleted file mode 100644
index dabdde489b..0000000000
--- a/synapse/storage/schema/delta/55/users_alter_deactivated.sql
+++ /dev/null
@@ -1,19 +0,0 @@
-/* Copyright 2019 The Matrix.org Foundation C.I.C.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-ALTER TABLE users ADD deactivated SMALLINT DEFAULT 0 NOT NULL;
-
-INSERT INTO background_updates (update_name, progress_json) VALUES
-  ('users_set_deactivated_flag', '{}');
diff --git a/synapse/storage/schema/delta/56/add_spans_to_device_lists.sql b/synapse/storage/schema/delta/56/add_spans_to_device_lists.sql
deleted file mode 100644
index 41807eb1e7..0000000000
--- a/synapse/storage/schema/delta/56/add_spans_to_device_lists.sql
+++ /dev/null
@@ -1,20 +0,0 @@
-/* Copyright 2019 The Matrix.org Foundation C.I.C
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * Opentracing context data for inclusion in the device_list_update EDUs, as a
- * json-encoded dictionary. NULL if opentracing is disabled (or not enabled for this destination).
- */
-ALTER TABLE device_lists_outbound_pokes ADD opentracing_context TEXT;
diff --git a/synapse/storage/schema/delta/56/current_state_events_membership.sql b/synapse/storage/schema/delta/56/current_state_events_membership.sql
deleted file mode 100644
index 473018676f..0000000000
--- a/synapse/storage/schema/delta/56/current_state_events_membership.sql
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Copyright 2019 The Matrix.org Foundation C.I.C.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
--- We add membership to current state so that we don't need to join against
--- room_memberships, which can be surprisingly costly (we do such queries
--- very frequently).
--- This will be null for non-membership events and the content.membership key
--- for membership events. (Will also be null for membership events until the
--- background update job has finished).
-ALTER TABLE current_state_events ADD membership TEXT;
diff --git a/synapse/storage/schema/delta/56/current_state_events_membership_mk2.sql b/synapse/storage/schema/delta/56/current_state_events_membership_mk2.sql
deleted file mode 100644
index 3133d42d4a..0000000000
--- a/synapse/storage/schema/delta/56/current_state_events_membership_mk2.sql
+++ /dev/null
@@ -1,24 +0,0 @@
-/* Copyright 2019 The Matrix.org Foundation C.I.C.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
--- We add membership to current state so that we don't need to join against
--- room_memberships, which can be surprisingly costly (we do such queries
--- very frequently).
--- This will be null for non-membership events and the content.membership key
--- for membership events. (Will also be null for membership events until the
--- background update job has finished).
-
-INSERT INTO background_updates (update_name, progress_json) VALUES
-  ('current_state_events_membership', '{}');
diff --git a/synapse/storage/schema/delta/56/destinations_failure_ts.sql b/synapse/storage/schema/delta/56/destinations_failure_ts.sql
deleted file mode 100644
index f00889290b..0000000000
--- a/synapse/storage/schema/delta/56/destinations_failure_ts.sql
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Copyright 2019 The Matrix.org Foundation C.I.C
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * Record the timestamp when a given server started failing
- */
-ALTER TABLE destinations ADD failure_ts BIGINT;
-
-/* as a rough approximation, we assume that the server started failing at
- * retry_interval before the last retry
- */
-UPDATE destinations SET failure_ts = retry_last_ts - retry_interval
-    WHERE retry_last_ts > 0;
diff --git a/synapse/storage/schema/delta/56/destinations_retry_interval_type.sql.postgres b/synapse/storage/schema/delta/56/destinations_retry_interval_type.sql.postgres
deleted file mode 100644
index b9bbb18a91..0000000000
--- a/synapse/storage/schema/delta/56/destinations_retry_interval_type.sql.postgres
+++ /dev/null
@@ -1,18 +0,0 @@
-/* Copyright 2019 The Matrix.org Foundation C.I.C
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
--- We want to store large retry intervals so we upgrade the column from INT
--- to BIGINT. We don't need to do this on SQLite.
-ALTER TABLE destinations ALTER retry_interval SET DATA TYPE BIGINT;
diff --git a/synapse/storage/schema/delta/56/devices_last_seen.sql b/synapse/storage/schema/delta/56/devices_last_seen.sql
deleted file mode 100644
index dfa902d0ba..0000000000
--- a/synapse/storage/schema/delta/56/devices_last_seen.sql
+++ /dev/null
@@ -1,24 +0,0 @@
-/* Copyright 2019 Matrix.org Foundation CIC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
--- Track last seen information for a device in the devices table, rather
--- than relying on it being in the user_ips table (which we want to be able
--- to purge old entries from)
-ALTER TABLE devices ADD COLUMN last_seen BIGINT;
-ALTER TABLE devices ADD COLUMN ip TEXT;
-ALTER TABLE devices ADD COLUMN user_agent TEXT;
-
-INSERT INTO background_updates (update_name, progress_json) VALUES
-  ('devices_last_seen', '{}');
diff --git a/synapse/storage/schema/delta/56/drop_unused_event_tables.sql b/synapse/storage/schema/delta/56/drop_unused_event_tables.sql
deleted file mode 100644
index 9f09922c67..0000000000
--- a/synapse/storage/schema/delta/56/drop_unused_event_tables.sql
+++ /dev/null
@@ -1,20 +0,0 @@
-/* Copyright 2019 The Matrix.org Foundation C.I.C.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
--- these tables are never used.
-DROP TABLE IF EXISTS room_names;
-DROP TABLE IF EXISTS topics;
-DROP TABLE IF EXISTS history_visibility;
-DROP TABLE IF EXISTS guest_access;
diff --git a/synapse/storage/schema/delta/56/fix_room_keys_index.sql b/synapse/storage/schema/delta/56/fix_room_keys_index.sql
deleted file mode 100644
index 014cb3b538..0000000000
--- a/synapse/storage/schema/delta/56/fix_room_keys_index.sql
+++ /dev/null
@@ -1,18 +0,0 @@
-/* Copyright 2019 Matrix.org Foundation CIC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
--- version is supposed to be part of the room keys index
-CREATE UNIQUE INDEX e2e_room_keys_with_version_idx ON e2e_room_keys(user_id, version, room_id, session_id);
-DROP INDEX IF EXISTS e2e_room_keys_idx;
diff --git a/synapse/storage/schema/delta/56/public_room_list_idx.sql b/synapse/storage/schema/delta/56/public_room_list_idx.sql
deleted file mode 100644
index 7be31ffebb..0000000000
--- a/synapse/storage/schema/delta/56/public_room_list_idx.sql
+++ /dev/null
@@ -1,16 +0,0 @@
-/* Copyright 2019 The Matrix.org Foundation C.I.C.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-CREATE INDEX public_room_list_stream_network ON public_room_list_stream (appservice_id, network_id, room_id);
diff --git a/synapse/storage/schema/delta/56/redaction_censor.sql b/synapse/storage/schema/delta/56/redaction_censor.sql
deleted file mode 100644
index fe51b02309..0000000000
--- a/synapse/storage/schema/delta/56/redaction_censor.sql
+++ /dev/null
@@ -1,17 +0,0 @@
-/* Copyright 2019 The Matrix.org Foundation C.I.C.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-ALTER TABLE redactions ADD COLUMN have_censored BOOL NOT NULL DEFAULT false;
-CREATE INDEX redactions_have_censored ON redactions(event_id) WHERE not have_censored;
diff --git a/synapse/storage/schema/delta/56/redaction_censor2.sql b/synapse/storage/schema/delta/56/redaction_censor2.sql
deleted file mode 100644
index 77a5eca499..0000000000
--- a/synapse/storage/schema/delta/56/redaction_censor2.sql
+++ /dev/null
@@ -1,20 +0,0 @@
-/* Copyright 2019 The Matrix.org Foundation C.I.C.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-ALTER TABLE redactions ADD COLUMN received_ts BIGINT;
-CREATE INDEX redactions_have_censored_ts ON redactions(received_ts) WHERE not have_censored;
-
-INSERT INTO background_updates (update_name, progress_json) VALUES
-  ('redactions_received_ts', '{}');
diff --git a/synapse/storage/schema/delta/56/redaction_censor3_fix_update.sql.postgres b/synapse/storage/schema/delta/56/redaction_censor3_fix_update.sql.postgres
deleted file mode 100644
index 67471f3ef5..0000000000
--- a/synapse/storage/schema/delta/56/redaction_censor3_fix_update.sql.postgres
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Copyright 2019 The Matrix.org Foundation C.I.C.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
--- There was a bug where we may have updated censored redactions as bytes,
--- which can (somehow) cause json to be inserted hex encoded. These updates go
--- and undoes any such hex encoded JSON.
-
-INSERT into background_updates (update_name, progress_json)
-  VALUES ('event_fix_redactions_bytes_create_index', '{}');
-
-INSERT into background_updates (update_name, progress_json, depends_on)
-  VALUES ('event_fix_redactions_bytes', '{}', 'event_fix_redactions_bytes_create_index');
diff --git a/synapse/storage/schema/delta/56/room_membership_idx.sql b/synapse/storage/schema/delta/56/room_membership_idx.sql
deleted file mode 100644
index 92ab1f5e65..0000000000
--- a/synapse/storage/schema/delta/56/room_membership_idx.sql
+++ /dev/null
@@ -1,18 +0,0 @@
-/* Copyright 2019 The Matrix.org Foundation C.I.C.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
--- Adds an index on room_memberships for fetching all forgotten rooms for a user
-INSERT INTO background_updates (update_name, progress_json) VALUES
-  ('room_membership_forgotten_idx', '{}');
diff --git a/synapse/storage/schema/delta/56/stats_separated.sql b/synapse/storage/schema/delta/56/stats_separated.sql
deleted file mode 100644
index 163529c071..0000000000
--- a/synapse/storage/schema/delta/56/stats_separated.sql
+++ /dev/null
@@ -1,152 +0,0 @@
-/* Copyright 2018 New Vector Ltd
- * Copyright 2019 The Matrix.org Foundation C.I.C.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
------ First clean up from previous versions of room stats.
-
--- First remove old stats stuff
-DROP TABLE IF EXISTS room_stats;
-DROP TABLE IF EXISTS room_state;
-DROP TABLE IF EXISTS room_stats_state;
-DROP TABLE IF EXISTS user_stats;
-DROP TABLE IF EXISTS room_stats_earliest_tokens;
-DROP TABLE IF EXISTS _temp_populate_stats_position;
-DROP TABLE IF EXISTS _temp_populate_stats_rooms;
-DROP TABLE IF EXISTS stats_stream_pos;
-
--- Unschedule old background updates if they're still scheduled
-DELETE FROM background_updates WHERE update_name IN (
-    'populate_stats_createtables',
-    'populate_stats_process_rooms',
-    'populate_stats_process_users',
-    'populate_stats_cleanup'
-);
-
-INSERT INTO background_updates (update_name, progress_json, depends_on) VALUES
-    ('populate_stats_process_rooms', '{}', '');
-
-INSERT INTO background_updates (update_name, progress_json, depends_on) VALUES
-    ('populate_stats_process_users', '{}', 'populate_stats_process_rooms');
-
------ Create tables for our version of room stats.
-
--- single-row table to track position of incremental updates
-DROP TABLE IF EXISTS stats_incremental_position;
-CREATE TABLE stats_incremental_position (
-    Lock CHAR(1) NOT NULL DEFAULT 'X' UNIQUE,  -- Makes sure this table only has one row.
-    stream_id  BIGINT NOT NULL,
-    CHECK (Lock='X')
-);
-
--- insert a null row and make sure it is the only one.
-INSERT INTO stats_incremental_position (
-    stream_id
-) SELECT COALESCE(MAX(stream_ordering), 0) from events;
-
--- represents PRESENT room statistics for a room
--- only holds absolute fields
-DROP TABLE IF EXISTS room_stats_current;
-CREATE TABLE room_stats_current (
-    room_id TEXT NOT NULL PRIMARY KEY,
-
-    -- These are absolute counts
-    current_state_events INT NOT NULL,
-    joined_members INT NOT NULL,
-    invited_members INT NOT NULL,
-    left_members INT NOT NULL,
-    banned_members INT NOT NULL,
-
-    local_users_in_room INT NOT NULL,
-
-    -- The maximum delta stream position that this row takes into account.
-    completed_delta_stream_id BIGINT NOT NULL
-);
-
-
--- represents HISTORICAL room statistics for a room
-DROP TABLE IF EXISTS room_stats_historical;
-CREATE TABLE room_stats_historical (
-    room_id TEXT NOT NULL,
-    -- These stats cover the time from (end_ts - bucket_size)...end_ts (in ms).
-    -- Note that end_ts is quantised.
-    end_ts BIGINT NOT NULL,
-    bucket_size BIGINT NOT NULL,
-
-    -- These stats are absolute counts
-    current_state_events BIGINT NOT NULL,
-    joined_members BIGINT NOT NULL,
-    invited_members BIGINT NOT NULL,
-    left_members BIGINT NOT NULL,
-    banned_members BIGINT NOT NULL,
-    local_users_in_room BIGINT NOT NULL,
-
-    -- These stats are per time slice
-    total_events BIGINT NOT NULL,
-    total_event_bytes BIGINT NOT NULL,
-
-    PRIMARY KEY (room_id, end_ts)
-);
-
--- We use this index to speed up deletion of ancient room stats.
-CREATE INDEX room_stats_historical_end_ts ON room_stats_historical (end_ts);
-
--- represents PRESENT statistics for a user
--- only holds absolute fields
-DROP TABLE IF EXISTS user_stats_current;
-CREATE TABLE user_stats_current (
-    user_id TEXT NOT NULL PRIMARY KEY,
-
-    joined_rooms BIGINT NOT NULL,
-
-    -- The maximum delta stream position that this row takes into account.
-    completed_delta_stream_id BIGINT NOT NULL
-);
-
--- represents HISTORICAL statistics for a user
-DROP TABLE IF EXISTS user_stats_historical;
-CREATE TABLE user_stats_historical (
-    user_id TEXT NOT NULL,
-    end_ts BIGINT NOT NULL,
-    bucket_size BIGINT NOT NULL,
-
-    joined_rooms BIGINT NOT NULL,
-
-    invites_sent BIGINT NOT NULL,
-    rooms_created BIGINT NOT NULL,
-    total_events BIGINT NOT NULL,
-    total_event_bytes BIGINT NOT NULL,
-
-    PRIMARY KEY (user_id, end_ts)
-);
-
--- We use this index to speed up deletion of ancient user stats.
-CREATE INDEX user_stats_historical_end_ts ON user_stats_historical (end_ts);
-
-
-CREATE TABLE room_stats_state (
-    room_id TEXT NOT NULL,
-    name TEXT,
-    canonical_alias TEXT,
-    join_rules TEXT,
-    history_visibility TEXT,
-    encryption TEXT,
-    avatar TEXT,
-    guest_access TEXT,
-    is_federatable BOOLEAN,
-    topic TEXT
-);
-
-CREATE UNIQUE INDEX room_stats_state_room ON room_stats_state(room_id);
diff --git a/synapse/storage/schema/delta/56/unique_user_filter_index.py b/synapse/storage/schema/delta/56/unique_user_filter_index.py
deleted file mode 100644
index 1de8b54961..0000000000
--- a/synapse/storage/schema/delta/56/unique_user_filter_index.py
+++ /dev/null
@@ -1,52 +0,0 @@
-import logging
-
-from synapse.storage.engines import PostgresEngine
-
-logger = logging.getLogger(__name__)
-
-
-"""
-This migration updates the user_filters table as follows:
-
- - drops any (user_id, filter_id) duplicates
- - makes the columns NON-NULLable
- - turns the index into a UNIQUE index
-"""
-
-
-def run_upgrade(cur, database_engine, *args, **kwargs):
-    pass
-
-
-def run_create(cur, database_engine, *args, **kwargs):
-    if isinstance(database_engine, PostgresEngine):
-        select_clause = """
-            SELECT DISTINCT ON (user_id, filter_id) user_id, filter_id, filter_json
-            FROM user_filters
-        """
-    else:
-        select_clause = """
-            SELECT * FROM user_filters GROUP BY user_id, filter_id
-        """
-    sql = """
-            DROP TABLE IF EXISTS user_filters_migration;
-            DROP INDEX IF EXISTS user_filters_unique;
-            CREATE TABLE user_filters_migration (
-                user_id TEXT NOT NULL,
-                filter_id BIGINT NOT NULL,
-                filter_json BYTEA NOT NULL
-            );
-            INSERT INTO user_filters_migration (user_id, filter_id, filter_json)
-                %s;
-            CREATE UNIQUE INDEX user_filters_unique ON user_filters_migration
-                (user_id, filter_id);
-            DROP TABLE user_filters;
-            ALTER TABLE user_filters_migration RENAME TO user_filters;
-        """ % (
-        select_clause,
-    )
-
-    if isinstance(database_engine, PostgresEngine):
-        cur.execute(sql)
-    else:
-        cur.executescript(sql)
diff --git a/synapse/storage/schema/delta/56/user_external_ids.sql b/synapse/storage/schema/delta/56/user_external_ids.sql
deleted file mode 100644
index 91390c4527..0000000000
--- a/synapse/storage/schema/delta/56/user_external_ids.sql
+++ /dev/null
@@ -1,24 +0,0 @@
-/* Copyright 2019 The Matrix.org Foundation C.I.C.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * a table which records mappings from external auth providers to mxids
- */
-CREATE TABLE IF NOT EXISTS user_external_ids (
-    auth_provider TEXT NOT NULL,
-    external_id TEXT NOT NULL,
-    user_id TEXT NOT NULL,
-    UNIQUE (auth_provider, external_id)
-);
diff --git a/synapse/storage/schema/delta/56/users_in_public_rooms_idx.sql b/synapse/storage/schema/delta/56/users_in_public_rooms_idx.sql
deleted file mode 100644
index 149f8be8b6..0000000000
--- a/synapse/storage/schema/delta/56/users_in_public_rooms_idx.sql
+++ /dev/null
@@ -1,17 +0,0 @@
-/* Copyright 2019 Matrix.org Foundation CIC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
--- this was apparently forgotten when the table was created back in delta 53.
-CREATE INDEX users_in_public_rooms_r_idx ON users_in_public_rooms(room_id);