mirror of
https://mau.dev/maunium/synapse.git
synced 2024-10-01 01:36:05 -04:00
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
This commit is contained in:
parent
7fc1e17f4c
commit
2d951686a7
1
changelog.d/4992.misc
Normal file
1
changelog.d/4992.misc
Normal file
@ -0,0 +1 @@
|
||||
Remove legacy tables detailed in #1830.
|
@ -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",
|
||||
@ -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",
|
||||
|
@ -1179,14 +1179,10 @@ class EventsStore(
|
||||
"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",
|
||||
@ -1857,16 +1853,12 @@ class EventsStore(
|
||||
# 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
|
||||
@ -2065,14 +2057,10 @@ class EventsStore(
|
||||
"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)
|
||||
|
@ -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.
|
||||
*/
|
||||
|
@ -1,42 +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 as json
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def run_create(cur, *args, **kwargs):
|
||||
cur.execute("SELECT id, regex FROM application_services_regex")
|
||||
for row in cur.fetchall():
|
||||
try:
|
||||
logger.debug("Checking %s..." % row[0])
|
||||
json.loads(row[1])
|
||||
except ValueError:
|
||||
# row isn't in json, make it so.
|
||||
string_regex = row[1]
|
||||
new_regex = json.dumps({
|
||||
"regex": string_regex,
|
||||
"exclusive": True
|
||||
})
|
||||
cur.execute(
|
||||
"UPDATE application_services_regex SET regex=? WHERE id=?",
|
||||
(new_regex, row[0])
|
||||
)
|
||||
|
||||
|
||||
def run_upgrade(*args, **kwargs):
|
||||
pass
|
@ -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
|
||||
|
@ -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.
|
||||
@ -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.
|
||||
*/
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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.
|
||||
@ -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
|
||||
);
|
@ -1,91 +0,0 @@
|
||||
/* Copyright 2014-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 event_forward_extremities(
|
||||
event_id TEXT NOT NULL,
|
||||
room_id TEXT NOT NULL,
|
||||
UNIQUE (event_id, room_id)
|
||||
);
|
||||
|
||||
CREATE INDEX ev_extrem_room ON event_forward_extremities(room_id);
|
||||
CREATE INDEX ev_extrem_id ON event_forward_extremities(event_id);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS event_backward_extremities(
|
||||
event_id TEXT NOT NULL,
|
||||
room_id TEXT NOT NULL,
|
||||
UNIQUE (event_id, room_id)
|
||||
);
|
||||
|
||||
CREATE INDEX ev_b_extrem_room ON event_backward_extremities(room_id);
|
||||
CREATE INDEX ev_b_extrem_id ON event_backward_extremities(event_id);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS event_edges(
|
||||
event_id TEXT NOT NULL,
|
||||
prev_event_id TEXT NOT NULL,
|
||||
room_id TEXT NOT NULL,
|
||||
-- We no longer insert prev_state into this table, so all new rows will have
|
||||
-- is_state as false.
|
||||
is_state BOOL NOT NULL,
|
||||
UNIQUE (event_id, prev_event_id, room_id, is_state)
|
||||
);
|
||||
|
||||
CREATE INDEX ev_edges_id ON event_edges(event_id);
|
||||
CREATE INDEX ev_edges_prev_id ON event_edges(prev_event_id);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS room_depth(
|
||||
room_id TEXT NOT NULL,
|
||||
min_depth INTEGER NOT NULL,
|
||||
UNIQUE (room_id)
|
||||
);
|
||||
|
||||
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,
|
||||
room_id TEXT NOT NULL,
|
||||
UNIQUE (event_id, auth_id, room_id)
|
||||
);
|
||||
|
||||
CREATE INDEX evauth_edges_id ON event_auth(event_id);
|
||||
CREATE INDEX evauth_edges_auth_id ON event_auth(auth_id);
|
@ -1,55 +0,0 @@
|
||||
/* Copyright 2014-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 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);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS event_reference_hashes (
|
||||
event_id TEXT,
|
||||
algorithm TEXT,
|
||||
hash bytea,
|
||||
UNIQUE (event_id, algorithm)
|
||||
);
|
||||
|
||||
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);
|
@ -1,123 +0,0 @@
|
||||
/* Copyright 2014-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 events(
|
||||
stream_ordering INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
topological_ordering BIGINT NOT NULL,
|
||||
event_id TEXT NOT NULL,
|
||||
type TEXT NOT NULL,
|
||||
room_id TEXT NOT NULL,
|
||||
content TEXT NOT NULL,
|
||||
unrecognized_keys TEXT,
|
||||
processed BOOL NOT NULL,
|
||||
outlier BOOL NOT NULL,
|
||||
depth BIGINT DEFAULT 0 NOT NULL,
|
||||
UNIQUE (event_id)
|
||||
);
|
||||
|
||||
CREATE INDEX events_stream_ordering ON events (stream_ordering);
|
||||
CREATE INDEX events_topological_ordering ON events (topological_ordering);
|
||||
CREATE INDEX events_room_id ON events (room_id);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS event_json(
|
||||
event_id TEXT NOT NULL,
|
||||
room_id TEXT NOT NULL,
|
||||
internal_metadata TEXT NOT NULL,
|
||||
json TEXT NOT NULL,
|
||||
UNIQUE (event_id)
|
||||
);
|
||||
|
||||
CREATE INDEX event_json_room_id ON event_json(room_id);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS state_events(
|
||||
event_id TEXT NOT NULL,
|
||||
room_id TEXT NOT NULL,
|
||||
type TEXT NOT NULL,
|
||||
state_key TEXT NOT NULL,
|
||||
prev_state TEXT,
|
||||
UNIQUE (event_id)
|
||||
);
|
||||
|
||||
CREATE INDEX state_events_room_id ON state_events (room_id);
|
||||
CREATE INDEX state_events_type ON state_events (type);
|
||||
CREATE INDEX state_events_state_key ON state_events (state_key);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS current_state_events(
|
||||
event_id TEXT NOT NULL,
|
||||
room_id TEXT NOT NULL,
|
||||
type TEXT NOT NULL,
|
||||
state_key TEXT NOT NULL,
|
||||
UNIQUE (room_id, type, state_key)
|
||||
);
|
||||
|
||||
CREATE INDEX curr_events_event_id ON current_state_events (event_id);
|
||||
CREATE INDEX current_state_events_room_id ON current_state_events (room_id);
|
||||
CREATE INDEX current_state_events_type ON current_state_events (type);
|
||||
CREATE INDEX current_state_events_state_key ON current_state_events (state_key);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS room_memberships(
|
||||
event_id TEXT NOT NULL,
|
||||
user_id TEXT NOT NULL,
|
||||
sender TEXT NOT NULL,
|
||||
room_id TEXT NOT NULL,
|
||||
membership TEXT NOT NULL
|
||||
);
|
||||
|
||||
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,
|
||||
topic TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE INDEX topics_event_id ON topics(event_id);
|
||||
CREATE INDEX topics_room_id ON topics(room_id);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS room_names(
|
||||
event_id TEXT NOT NULL,
|
||||
room_id TEXT NOT NULL,
|
||||
name TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE INDEX room_names_event_id ON room_names(event_id);
|
||||
CREATE INDEX room_names_room_id ON room_names(room_id);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS rooms(
|
||||
room_id TEXT PRIMARY KEY NOT NULL,
|
||||
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);
|
@ -1,31 +0,0 @@
|
||||
/* Copyright 2014-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_tls_certificates(
|
||||
server_name TEXT, -- Server name.
|
||||
fingerprint TEXT, -- Certificate fingerprint.
|
||||
from_server TEXT, -- Which key server the certificate was fetched from.
|
||||
ts_added_ms BIGINT, -- When the certifcate was added.
|
||||
tls_certificate bytea, -- DER encoded x509 certificate.
|
||||
UNIQUE (server_name, fingerprint)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS server_signature_keys(
|
||||
server_name TEXT, -- Server name.
|
||||
key_id TEXT, -- Key version.
|
||||
from_server TEXT, -- Which key server the key was fetched form.
|
||||
ts_added_ms BIGINT, -- When the key was added.
|
||||
verify_key bytea, -- NACL verification key.
|
||||
UNIQUE (server_name, key_id)
|
||||
);
|
@ -1,65 +0,0 @@
|
||||
/* Copyright 2014-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 local_media_repository (
|
||||
media_id TEXT, -- The id used to refer to the media.
|
||||
media_type TEXT, -- The MIME-type of the media.
|
||||
media_length INTEGER, -- Length of the media in bytes.
|
||||
created_ts BIGINT, -- When the content was uploaded in ms.
|
||||
upload_name TEXT, -- The name the media was uploaded with.
|
||||
user_id TEXT, -- The user who uploaded the file.
|
||||
UNIQUE (media_id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS local_media_repository_thumbnails (
|
||||
media_id TEXT, -- The id used to refer to the media.
|
||||
thumbnail_width INTEGER, -- The width of the thumbnail in pixels.
|
||||
thumbnail_height INTEGER, -- The height of the thumbnail in pixels.
|
||||
thumbnail_type TEXT, -- The MIME-type of the thumbnail.
|
||||
thumbnail_method TEXT, -- The method used to make the thumbnail.
|
||||
thumbnail_length INTEGER, -- The length of the thumbnail in bytes.
|
||||
UNIQUE (
|
||||
media_id, thumbnail_width, thumbnail_height, thumbnail_type
|
||||
)
|
||||
);
|
||||
|
||||
CREATE INDEX local_media_repository_thumbnails_media_id
|
||||
ON local_media_repository_thumbnails (media_id);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS remote_media_cache (
|
||||
media_origin TEXT, -- The remote HS the media came from.
|
||||
media_id TEXT, -- The id used to refer to the media on that server.
|
||||
media_type TEXT, -- The MIME-type of the media.
|
||||
created_ts BIGINT, -- When the content was uploaded in ms.
|
||||
upload_name TEXT, -- The name the media was uploaded with.
|
||||
media_length INTEGER, -- Length of the media in bytes.
|
||||
filesystem_id TEXT, -- The name used to store the media on disk.
|
||||
UNIQUE (media_origin, media_id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS remote_media_cache_thumbnails (
|
||||
media_origin TEXT, -- The remote HS the media came from.
|
||||
media_id TEXT, -- The id used to refer to the media.
|
||||
thumbnail_width INTEGER, -- The width of the thumbnail in pixels.
|
||||
thumbnail_height INTEGER, -- The height of the thumbnail in pixels.
|
||||
thumbnail_method TEXT, -- The method used to make the thumbnail
|
||||
thumbnail_type TEXT, -- The MIME-type of the thumbnail.
|
||||
thumbnail_length INTEGER, -- The length of the thumbnail in bytes.
|
||||
filesystem_id TEXT, -- The name used to store the media on disk.
|
||||
UNIQUE (
|
||||
media_origin, media_id, thumbnail_width, thumbnail_height,
|
||||
thumbnail_type
|
||||
)
|
||||
);
|
@ -1,35 +0,0 @@
|
||||
/* Copyright 2014-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 presence(
|
||||
user_id TEXT NOT NULL,
|
||||
state VARCHAR(20),
|
||||
status_msg TEXT,
|
||||
mtime BIGINT -- miliseconds since last state change
|
||||
);
|
||||
|
||||
-- For each of /my/ users which possibly-remote users are allowed to see their
|
||||
-- presence state
|
||||
CREATE TABLE IF NOT EXISTS presence_allow_inbound(
|
||||
observed_user_id TEXT NOT NULL,
|
||||
observer_user_id TEXT NOT NULL -- a UserID,
|
||||
);
|
||||
|
||||
-- For each of /my/ users (watcher), which possibly-remote users are they
|
||||
-- watching?
|
||||
CREATE TABLE IF NOT EXISTS presence_list(
|
||||
user_id TEXT NOT NULL,
|
||||
observed_user_id TEXT NOT NULL, -- a UserID,
|
||||
accepted BOOLEAN NOT NULL
|
||||
);
|
@ -1,19 +0,0 @@
|
||||
/* Copyright 2014-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 profiles(
|
||||
user_id TEXT NOT NULL,
|
||||
displayname TEXT,
|
||||
avatar_url TEXT
|
||||
);
|
@ -1,22 +0,0 @@
|
||||
/* Copyright 2014-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 redactions (
|
||||
event_id TEXT NOT NULL,
|
||||
redacts TEXT NOT NULL,
|
||||
UNIQUE (event_id)
|
||||
);
|
||||
|
||||
CREATE INDEX redactions_event_id ON redactions (event_id);
|
||||
CREATE INDEX redactions_redacts ON redactions (redacts);
|
@ -1,40 +0,0 @@
|
||||
/* Copyright 2014-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 state_groups(
|
||||
id INTEGER PRIMARY KEY,
|
||||
room_id TEXT NOT NULL,
|
||||
event_id TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS state_groups_state(
|
||||
state_group INTEGER NOT NULL,
|
||||
room_id TEXT NOT NULL,
|
||||
type TEXT NOT NULL,
|
||||
state_key TEXT NOT NULL,
|
||||
event_id TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS event_to_state_groups(
|
||||
event_id TEXT NOT NULL,
|
||||
state_group INTEGER NOT NULL,
|
||||
UNIQUE (event_id)
|
||||
);
|
||||
|
||||
CREATE INDEX state_groups_id ON state_groups(id);
|
||||
|
||||
CREATE INDEX state_groups_state_id ON state_groups_state(state_group);
|
||||
CREATE INDEX state_groups_state_tuple ON state_groups_state(room_id, type, state_key);
|
||||
CREATE INDEX event_to_state_groups_id ON event_to_state_groups(event_id);
|
@ -1,44 +0,0 @@
|
||||
/* Copyright 2014-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 what transaction ids we have received and what our response was
|
||||
CREATE TABLE IF NOT EXISTS received_transactions(
|
||||
transaction_id TEXT,
|
||||
origin TEXT,
|
||||
ts BIGINT,
|
||||
response_code INTEGER,
|
||||
response_json bytea,
|
||||
has_been_referenced SMALLINT DEFAULT 0, -- Whether thishas been referenced by a prev_tx
|
||||
UNIQUE (transaction_id, origin)
|
||||
);
|
||||
|
||||
CREATE INDEX transactions_have_ref ON received_transactions(origin, has_been_referenced);-- WHERE has_been_referenced = 0;
|
||||
|
||||
-- For sent transactions only.
|
||||
CREATE TABLE IF NOT EXISTS transaction_id_to_pdu(
|
||||
transaction_id INTEGER,
|
||||
destination TEXT,
|
||||
pdu_id TEXT,
|
||||
pdu_origin TEXT
|
||||
);
|
||||
|
||||
CREATE INDEX transaction_id_to_pdu_tx ON transaction_id_to_pdu(transaction_id, destination);
|
||||
CREATE INDEX transaction_id_to_pdu_dest ON transaction_id_to_pdu(destination);
|
||||
|
||||
-- To track destination health
|
||||
CREATE TABLE IF NOT EXISTS destinations(
|
||||
destination TEXT PRIMARY KEY,
|
||||
retry_last_ts BIGINT,
|
||||
retry_interval INTEGER
|
||||
);
|
@ -1,43 +0,0 @@
|
||||
/* Copyright 2014-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 users(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
name TEXT,
|
||||
password_hash TEXT,
|
||||
creation_ts BIGINT,
|
||||
admin SMALLINT DEFAULT 0 NOT NULL,
|
||||
UNIQUE(name)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS access_tokens(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
user_id TEXT NOT NULL,
|
||||
device_id TEXT,
|
||||
token TEXT NOT NULL,
|
||||
last_used BIGINT,
|
||||
UNIQUE(token)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS user_ips (
|
||||
user TEXT NOT NULL,
|
||||
access_token TEXT NOT NULL,
|
||||
device_id TEXT,
|
||||
ip TEXT NOT NULL,
|
||||
user_agent TEXT NOT NULL,
|
||||
last_seen BIGINT NOT NULL,
|
||||
UNIQUE (user, access_token, ip, user_agent)
|
||||
);
|
||||
|
||||
CREATE INDEX user_ips_user ON user_ips(user);
|
@ -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 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,
|
||||
|
@ -13,6 +13,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/* We used to create 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,
|
||||
@ -54,31 +59,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,
|
||||
|
@ -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 tables called event_content_hashes 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,
|
||||
@ -42,14 +36,3 @@ CREATE TABLE IF NOT EXISTS event_signatures (
|
||||
);
|
||||
|
||||
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);
|
||||
|
@ -13,6 +13,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/* We used to create 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,
|
||||
topological_ordering BIGINT NOT NULL,
|
||||
@ -91,15 +95,6 @@ CREATE TABLE IF NOT EXISTS room_memberships(
|
||||
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,
|
||||
UNIQUE (event_id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS topics(
|
||||
event_id TEXT NOT NULL,
|
||||
room_id TEXT NOT NULL,
|
||||
@ -123,11 +118,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);
|
||||
|
Loading…
Reference in New Issue
Block a user