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

drop tables listed in #1830 #4992

Merged
merged 28 commits into from
Apr 8, 2019
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
7adb9d0
first draft of remove presence lists
neilisfragile Apr 2, 2019
402d6e8
towncrier
neilisfragile Apr 2, 2019
ded3368
remove unused import
neilisfragile Apr 2, 2019
18488b0
delete all the things
neilisfragile Apr 2, 2019
0546e86
pep8
neilisfragile Apr 2, 2019
2a46f3a
delete
neilisfragile Apr 2, 2019
fde8ce6
include msc ref
neilisfragile Apr 2, 2019
aec4871
drop presence list table
neilisfragile Apr 2, 2019
5c7e783
delete
neilisfragile Apr 2, 2019
bacc037
town crier
neilisfragile Apr 2, 2019
fcae26e
.
neilisfragile Apr 2, 2019
11076bd
drop legacy tables via delta
neilisfragile Apr 2, 2019
2aec358
Merge branch 'develop' into neilj/drop_tables_in_1830
neilisfragile Apr 3, 2019
aeb6596
remove unused legacy tables
neilisfragile Apr 3, 2019
40340f4
Merge branch 'develop' of github.com:matrix-org/synapse into neilj/dr…
neilisfragile Apr 3, 2019
25744a1
fix drop tables, and bump schema version
neilisfragile Apr 3, 2019
1d39449
move to delta 55
neilisfragile Apr 3, 2019
54c6d6d
54->55
neilisfragile Apr 3, 2019
01b270e
55->54
neilisfragile Apr 3, 2019
9f747e8
55->54
neilisfragile Apr 3, 2019
8dcc771
55->54
neilisfragile Apr 3, 2019
7687d76
Since the dir has to exist, a file explaining why
neilisfragile Apr 3, 2019
c0b4a2d
app_services and app_servives_regex
neilisfragile Apr 3, 2019
3f0f7da
no longer used
neilisfragile Apr 3, 2019
bfbb541
fix typo
neilisfragile Apr 5, 2019
74e809a
remove old schema data
neilisfragile Apr 5, 2019
8b83064
Revert "remove old schema data"
neilisfragile Apr 8, 2019
41121e4
revert delta removal
neilisfragile Apr 8, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/* We used to create a tables called application_services and
/* We used to create tables called application_services and

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

likewise in a number of other places

* 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
30 changes: 30 additions & 0 deletions synapse/storage/schema/delta/54/drop_legacy_tables.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* 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 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;



30 changes: 5 additions & 25 deletions synapse/storage/schema/full_schemas/11/event_edges.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
* limitations under the License.
*/

/* We used to create a tables called event_destinations and
* state_forward_extremities, but these are no longer used and are removed in
* delta 54.
*/

CREATE TABLE IF NOT EXISTS event_forward_extremities(
event_id TEXT NOT NULL,
room_id TEXT NOT NULL,
Expand Down Expand Up @@ -55,31 +60,6 @@ CREATE TABLE IF NOT EXISTS room_depth(

CREATE INDEX room_depth_room ON room_depth(room_id);


create TABLE IF NOT EXISTS event_destinations(
event_id TEXT NOT NULL,
destination TEXT NOT NULL,
delivered_ts BIGINT DEFAULT 0, -- or 0 if not delivered
UNIQUE (event_id, destination)
);

CREATE INDEX event_destinations_id ON event_destinations(event_id);


CREATE TABLE IF NOT EXISTS state_forward_extremities(
event_id TEXT NOT NULL,
room_id TEXT NOT NULL,
type TEXT NOT NULL,
state_key TEXT NOT NULL,
UNIQUE (event_id, room_id)
);

CREATE INDEX st_extrem_keys ON state_forward_extremities(
room_id, type, state_key
);
CREATE INDEX st_extrem_id ON state_forward_extremities(event_id);


CREATE TABLE IF NOT EXISTS event_auth(
event_id TEXT NOT NULL,
auth_id TEXT NOT NULL,
Expand Down
34 changes: 3 additions & 31 deletions synapse/storage/schema/full_schemas/11/event_signatures.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,9 @@
* limitations under the License.
*/

CREATE TABLE IF NOT EXISTS event_content_hashes (
event_id TEXT,
algorithm TEXT,
hash bytea,
UNIQUE (event_id, algorithm)
);

CREATE INDEX event_content_hashes_id ON event_content_hashes(event_id);

/* We used to create a tables called event_content_hashes, event_signatures and
* event_edge_hashes, but these are no longer used and are removed in delta 54.
*/

CREATE TABLE IF NOT EXISTS event_reference_hashes (
event_id TEXT,
Expand All @@ -31,25 +25,3 @@ CREATE TABLE IF NOT EXISTS event_reference_hashes (
);

CREATE INDEX event_reference_hashes_id ON event_reference_hashes(event_id);


CREATE TABLE IF NOT EXISTS event_signatures (
event_id TEXT,
signature_name TEXT,
key_id TEXT,
signature bytea,
UNIQUE (event_id, signature_name, key_id)
);

CREATE INDEX event_signatures_id ON event_signatures(event_id);


CREATE TABLE IF NOT EXISTS event_edge_hashes(
event_id TEXT,
prev_event_id TEXT,
algorithm TEXT,
hash bytea,
UNIQUE (event_id, prev_event_id, algorithm)
);

CREATE INDEX event_edge_hashes_id ON event_edge_hashes(event_id);
20 changes: 4 additions & 16 deletions synapse/storage/schema/full_schemas/11/im.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
* limitations under the License.
*/

/* We used to create a tables called room_hosts and feedback,
* but these are no longer used and are removed in delta 54.
*/

CREATE TABLE IF NOT EXISTS events(
stream_ordering INTEGER PRIMARY KEY AUTOINCREMENT,
topological_ordering BIGINT NOT NULL,
Expand Down Expand Up @@ -82,14 +86,6 @@ CREATE INDEX room_memberships_event_id ON room_memberships (event_id);
CREATE INDEX room_memberships_room_id ON room_memberships (room_id);
CREATE INDEX room_memberships_user_id ON room_memberships (user_id);

CREATE TABLE IF NOT EXISTS feedback(
event_id TEXT NOT NULL,
feedback_type TEXT,
target_event_id TEXT,
sender TEXT,
room_id TEXT
);

CREATE TABLE IF NOT EXISTS topics(
event_id TEXT NOT NULL,
room_id TEXT NOT NULL,
Expand All @@ -113,11 +109,3 @@ CREATE TABLE IF NOT EXISTS rooms(
is_public BOOL,
creator TEXT
);

CREATE TABLE IF NOT EXISTS room_hosts(
room_id TEXT NOT NULL,
host TEXT NOT NULL,
UNIQUE (room_id, host)
);

CREATE INDEX room_hosts_room_id ON room_hosts (room_id);
19 changes: 4 additions & 15 deletions synapse/storage/schema/full_schemas/16/application_services.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,11 @@
* limitations under the License.
*/

CREATE TABLE IF NOT EXISTS application_services(
id BIGINT PRIMARY KEY,
url TEXT,
token TEXT,
hs_token TEXT,
sender TEXT,
UNIQUE(token)
);
/* 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.
*/

CREATE TABLE IF NOT EXISTS application_services_regex(
id BIGINT PRIMARY KEY,
as_id BIGINT NOT NULL,
namespace INTEGER, /* enum[room_id|room_alias|user_id] */
regex TEXT,
FOREIGN KEY(as_id) REFERENCES application_services(id)
);

CREATE TABLE IF NOT EXISTS application_services_state(
as_id TEXT PRIMARY KEY,
Expand Down
Loading