Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
drop tables listed in #1830 (#4992)
Browse files Browse the repository at this point in the history
Tables dropped: 
 * application_services, 
 * application_services_regex, 
 * transaction_id_to_pdu, 
 * stats_reporting
 * current_state_resets
 * event_content_hashes
 * event_destinations
 * event_edge_hashes
 * event_signatures
 * feedback
 * room_hosts
 * state_forward_extremities
  • Loading branch information
neilisfragile authored Apr 8, 2019
1 parent 7fc1e17 commit 2d95168
Show file tree
Hide file tree
Showing 26 changed files with 43 additions and 757 deletions.
1 change: 1 addition & 0 deletions changelog.d/4992.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove legacy tables detailed in #1830.
5 changes: 0 additions & 5 deletions scripts/synapse_port_db
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,11 @@ BOOLEAN_COLUMNS = {


APPEND_ONLY_TABLES = [
"event_content_hashes",
"event_reference_hashes",
"event_signatures",
"event_edge_hashes",
"events",
"event_json",
"state_events",
"room_memberships",
"feedback",
"topics",
"room_names",
"rooms",
Expand All @@ -88,7 +84,6 @@ APPEND_ONLY_TABLES = [
"event_search",
"presence_stream",
"push_rules_stream",
"current_state_resets",
"ex_outlier_stream",
"cache_invalidation_stream",
"public_room_list_stream",
Expand Down
12 changes: 0 additions & 12 deletions synapse/storage/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -1179,14 +1179,10 @@ def _delete_existing_rows_txn(cls, txn, events_and_contexts):
"events",
"event_auth",
"event_json",
"event_content_hashes",
"event_destinations",
"event_edge_hashes",
"event_edges",
"event_forward_extremities",
"event_reference_hashes",
"event_search",
"event_signatures",
"event_to_state_groups",
"guest_access",
"history_visibility",
Expand Down Expand Up @@ -1857,16 +1853,12 @@ def _purge_history_txn(self, txn, room_id, token_str, delete_local_events):
# Tables that should be pruned:
# event_auth
# event_backward_extremities
# event_content_hashes
# event_destinations
# event_edge_hashes
# event_edges
# event_forward_extremities
# event_json
# event_push_actions
# event_reference_hashes
# event_search
# event_signatures
# event_to_state_groups
# events
# rejections
Expand Down Expand Up @@ -2065,14 +2057,10 @@ def _purge_history_txn(self, txn, room_id, token_str, delete_local_events):
"events",
"event_json",
"event_auth",
"event_content_hashes",
"event_destinations",
"event_edge_hashes",
"event_edges",
"event_forward_extremities",
"event_reference_hashes",
"event_search",
"event_signatures",
"rejections",
):
logger.info("[purge] removing events from %s", table)
Expand Down
20 changes: 4 additions & 16 deletions synapse/storage/schema/delta/13/v13.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,7 @@
* limitations under the License.
*/

CREATE TABLE IF NOT EXISTS application_services(
id INTEGER PRIMARY KEY AUTOINCREMENT,
url TEXT,
token TEXT,
hs_token TEXT,
sender TEXT,
UNIQUE(token)
);

CREATE TABLE IF NOT EXISTS application_services_regex(
id INTEGER PRIMARY KEY AUTOINCREMENT,
as_id BIGINT UNSIGNED NOT NULL,
namespace INTEGER, /* enum[room_id|room_alias|user_id] */
regex TEXT,
FOREIGN KEY(as_id) REFERENCES application_services(id)
);
/* 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.
*/
42 changes: 0 additions & 42 deletions synapse/storage/schema/delta/14/upgrade_appservice_db.py

This file was deleted.

8 changes: 0 additions & 8 deletions synapse/storage/schema/delta/16/unique_constraints.sql
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@ DELETE FROM room_memberships WHERE rowid not in (
DROP INDEX IF EXISTS room_memberships_event_id;
CREATE UNIQUE INDEX room_memberships_event_id ON room_memberships(event_id);

--
DELETE FROM feedback WHERE rowid not in (
SELECT MIN(rowid) FROM feedback GROUP BY event_id
);

DROP INDEX IF EXISTS feedback_event_id;
CREATE UNIQUE INDEX feedback_event_id ON feedback(event_id);

--
DELETE FROM topics WHERE rowid not in (
SELECT MIN(rowid) FROM topics GROUP BY event_id
Expand Down
12 changes: 4 additions & 8 deletions synapse/storage/schema/delta/24/stats_reporting.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2015, 2016 OpenMarket Ltd
/* 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.
Expand All @@ -13,10 +13,6 @@
* limitations under the License.
*/

-- Should only ever contain one row
CREATE TABLE IF NOT EXISTS stats_reporting(
-- The stream ordering token which was most recently reported as stats
reported_stream_token INTEGER,
-- The time (seconds since epoch) stats were most recently reported
reported_time BIGINT
);
/* We used to create a table called stats_reporting, but this is no longer
* used and is removed in delta 54.
*/
9 changes: 2 additions & 7 deletions synapse/storage/schema/delta/30/state_stream.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,10 @@
*/


/**
* The positions in the event stream_ordering when the current_state was
* replaced by the state at the event.
/* We used to create a table called current_state_resets, but this is no
* longer used and is removed in delta 54.
*/

CREATE TABLE IF NOT EXISTS current_state_resets(
event_stream_ordering BIGINT PRIMARY KEY NOT NULL
);

/* 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
Expand Down
4 changes: 0 additions & 4 deletions synapse/storage/schema/delta/32/remove_indices.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,9 @@ 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 event_destinations_id; -- Prefix of UNIQUE CONSTRAINT
DROP INDEX IF EXISTS st_extrem_id; -- Prefix of UNIQUE CONSTRAINT
DROP INDEX IF EXISTS event_content_hashes_id; -- Prefix of UNIQUE CONSTRAINT
DROP INDEX IF EXISTS event_signatures_id; -- Prefix of UNIQUE CONSTRAINT
DROP INDEX IF EXISTS event_edge_hashes_id; -- Prefix of UNIQUE CONSTRAINT
DROP INDEX IF EXISTS redactions_event_id; -- Duplicate of UNIQUE CONSTRAINT
DROP INDEX IF EXISTS room_hosts_room_id; -- Prefix of UNIQUE CONSTRAINT

-- The following indices were unused
DROP INDEX IF EXISTS remote_media_cache_thumbnails_media_id;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2014-2016 OpenMarket Ltd
/* 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.
Expand All @@ -13,12 +13,18 @@
* limitations under the License.
*/

CREATE TABLE IF NOT EXISTS room_aliases(
room_alias TEXT NOT NULL,
room_id TEXT NOT NULL
);
DROP TABLE IF EXISTS application_services;
DROP TABLE IF EXISTS application_services_regex;
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 state_forward_extremities;



CREATE TABLE IF NOT EXISTS room_alias_servers(
room_alias TEXT NOT NULL,
server TEXT NOT NULL
);
91 changes: 0 additions & 91 deletions synapse/storage/schema/full_schemas/11/event_edges.sql

This file was deleted.

55 changes: 0 additions & 55 deletions synapse/storage/schema/full_schemas/11/event_signatures.sql

This file was deleted.

Loading

0 comments on commit 2d95168

Please sign in to comment.