mirror of
https://github.com/element-hq/synapse
synced 2024-08-20 01:30:20 +00:00
Change full_schemas/11 to work with postgres
This commit is contained in:
parent
5b31afcbd1
commit
cf04cedf21
13 changed files with 90 additions and 84 deletions
|
@ -1 +1,4 @@
|
|||
CREATE INDEX events_order ON events (topological_ordering, stream_ordering);
|
||||
CREATE INDEX events_order ON events (topological_ordering, stream_ordering);
|
||||
CREATE INDEX events_order_room ON events (
|
||||
room_id, topological_ordering, stream_ordering
|
||||
);
|
||||
|
|
|
@ -19,8 +19,8 @@ CREATE TABLE IF NOT EXISTS event_forward_extremities(
|
|||
UNIQUE (event_id, room_id)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS ev_extrem_room ON event_forward_extremities(room_id);
|
||||
CREATE INDEX IF NOT EXISTS ev_extrem_id ON event_forward_extremities(event_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(
|
||||
|
@ -29,8 +29,8 @@ CREATE TABLE IF NOT EXISTS event_backward_extremities(
|
|||
UNIQUE (event_id, room_id)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS ev_b_extrem_room ON event_backward_extremities(room_id);
|
||||
CREATE INDEX IF NOT EXISTS ev_b_extrem_id ON event_backward_extremities(event_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(
|
||||
|
@ -41,8 +41,8 @@ CREATE TABLE IF NOT EXISTS event_edges(
|
|||
UNIQUE (event_id, prev_event_id, room_id, is_state)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS ev_edges_id ON event_edges(event_id);
|
||||
CREATE INDEX IF NOT EXISTS ev_edges_prev_id ON event_edges(prev_event_id);
|
||||
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(
|
||||
|
@ -51,17 +51,17 @@ CREATE TABLE IF NOT EXISTS room_depth(
|
|||
UNIQUE (room_id)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS room_depth_room ON room_depth(room_id);
|
||||
CREATE INDEX room_depth_room ON room_depth(room_id);
|
||||
|
||||
|
||||
create TABLE IF NOT EXISTS event_destinations(
|
||||
event_id VARCHAR(150) NOT NULL,
|
||||
destination VARCHAR(150) NOT NULL,
|
||||
delivered_ts BIGINT UNSIGNED DEFAULT 0, -- or 0 if not delivered
|
||||
delivered_ts BIGINT DEFAULT 0, -- or 0 if not delivered
|
||||
UNIQUE (event_id, destination)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS event_destinations_id ON event_destinations(event_id);
|
||||
CREATE INDEX event_destinations_id ON event_destinations(event_id);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS state_forward_extremities(
|
||||
|
@ -72,10 +72,10 @@ CREATE TABLE IF NOT EXISTS state_forward_extremities(
|
|||
UNIQUE (event_id, room_id)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS st_extrem_keys ON state_forward_extremities(
|
||||
CREATE INDEX st_extrem_keys ON state_forward_extremities(
|
||||
room_id, type, state_key
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS st_extrem_id ON state_forward_extremities(event_id);
|
||||
CREATE INDEX st_extrem_id ON state_forward_extremities(event_id);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS event_auth(
|
||||
|
@ -85,5 +85,5 @@ CREATE TABLE IF NOT EXISTS event_auth(
|
|||
UNIQUE (event_id, auth_id, room_id)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS evauth_edges_id ON event_auth(event_id);
|
||||
CREATE INDEX IF NOT EXISTS evauth_edges_auth_id ON event_auth(auth_id);
|
||||
CREATE INDEX evauth_edges_id ON event_auth(event_id);
|
||||
CREATE INDEX evauth_edges_auth_id ON event_auth(auth_id);
|
||||
|
|
|
@ -16,40 +16,40 @@
|
|||
CREATE TABLE IF NOT EXISTS event_content_hashes (
|
||||
event_id VARCHAR(150),
|
||||
algorithm VARCHAR(150),
|
||||
hash LONGBLOB,
|
||||
hash bytea,
|
||||
UNIQUE (event_id, algorithm)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS event_content_hashes_id ON event_content_hashes(event_id);
|
||||
CREATE INDEX event_content_hashes_id ON event_content_hashes(event_id);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS event_reference_hashes (
|
||||
event_id VARCHAR(150),
|
||||
algorithm VARCHAR(150),
|
||||
hash LONGBLOB,
|
||||
hash bytea,
|
||||
UNIQUE (event_id, algorithm)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS event_reference_hashes_id ON event_reference_hashes(event_id);
|
||||
CREATE INDEX event_reference_hashes_id ON event_reference_hashes(event_id);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS event_signatures (
|
||||
event_id VARCHAR(150),
|
||||
signature_name VARCHAR(150),
|
||||
key_id VARCHAR(150),
|
||||
signature LONGBLOB,
|
||||
signature bytea,
|
||||
UNIQUE (event_id, signature_name, key_id)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS event_signatures_id ON event_signatures(event_id);
|
||||
CREATE INDEX event_signatures_id ON event_signatures(event_id);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS event_edge_hashes(
|
||||
event_id VARCHAR(150),
|
||||
prev_event_id VARCHAR(150),
|
||||
algorithm VARCHAR(150),
|
||||
hash LONGBLOB,
|
||||
hash bytea,
|
||||
UNIQUE (event_id, prev_event_id, algorithm)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS event_edge_hashes_id ON event_edge_hashes(event_id);
|
||||
CREATE INDEX event_edge_hashes_id ON event_edge_hashes(event_id);
|
||||
|
|
|
@ -15,32 +15,32 @@
|
|||
|
||||
CREATE TABLE IF NOT EXISTS events(
|
||||
stream_ordering INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
topological_ordering BIGINT UNSIGNED NOT NULL,
|
||||
topological_ordering BIGINT NOT NULL,
|
||||
event_id VARCHAR(150) NOT NULL,
|
||||
type VARCHAR(150) NOT NULL,
|
||||
room_id VARCHAR(150) NOT NULL,
|
||||
content LONGBLOB NOT NULL,
|
||||
unrecognized_keys LONGBLOB,
|
||||
content bytea NOT NULL,
|
||||
unrecognized_keys bytea,
|
||||
processed BOOL NOT NULL,
|
||||
outlier BOOL NOT NULL,
|
||||
depth BIGINT UNSIGNED DEFAULT 0 NOT NULL,
|
||||
depth BIGINT DEFAULT 0 NOT NULL,
|
||||
UNIQUE (event_id)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS events_stream_ordering ON events (stream_ordering);
|
||||
CREATE INDEX IF NOT EXISTS events_topological_ordering ON events (topological_ordering);
|
||||
CREATE INDEX IF NOT EXISTS events_room_id ON events (room_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 VARCHAR(150) NOT NULL,
|
||||
room_id VARCHAR(150) NOT NULL,
|
||||
internal_metadata LONGBLOB NOT NULL,
|
||||
json LONGBLOB NOT NULL,
|
||||
internal_metadata bytea NOT NULL,
|
||||
json bytea NOT NULL,
|
||||
UNIQUE (event_id)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS event_json_room_id ON event_json(room_id);
|
||||
CREATE INDEX event_json_room_id ON event_json(room_id);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS state_events(
|
||||
|
@ -52,9 +52,9 @@ CREATE TABLE IF NOT EXISTS state_events(
|
|||
UNIQUE (event_id)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS state_events_room_id ON state_events (room_id);
|
||||
CREATE INDEX IF NOT EXISTS state_events_type ON state_events (type);
|
||||
CREATE INDEX IF NOT EXISTS state_events_state_key ON state_events (state_key);
|
||||
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(
|
||||
|
@ -65,10 +65,10 @@ CREATE TABLE IF NOT EXISTS current_state_events(
|
|||
UNIQUE (room_id, type, state_key)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS curr_events_event_id ON current_state_events (event_id);
|
||||
CREATE INDEX IF NOT EXISTS current_state_events_room_id ON current_state_events (room_id);
|
||||
CREATE INDEX IF NOT EXISTS current_state_events_type ON current_state_events (type);
|
||||
CREATE INDEX IF NOT EXISTS current_state_events_state_key ON current_state_events (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 VARCHAR(150) NOT NULL,
|
||||
|
@ -78,9 +78,9 @@ CREATE TABLE IF NOT EXISTS room_memberships(
|
|||
membership VARCHAR(150) NOT NULL
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS room_memberships_event_id ON room_memberships (event_id);
|
||||
CREATE INDEX IF NOT EXISTS room_memberships_room_id ON room_memberships (room_id);
|
||||
CREATE INDEX IF NOT EXISTS room_memberships_user_id ON room_memberships (user_id);
|
||||
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 VARCHAR(150) NOT NULL,
|
||||
|
@ -96,8 +96,8 @@ CREATE TABLE IF NOT EXISTS topics(
|
|||
topic TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS topics_event_id ON topics(event_id);
|
||||
CREATE INDEX IF NOT EXISTS topics_room_id ON topics(room_id);
|
||||
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 VARCHAR(150) NOT NULL,
|
||||
|
@ -105,8 +105,8 @@ CREATE TABLE IF NOT EXISTS room_names(
|
|||
name TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS room_names_event_id ON room_names(event_id);
|
||||
CREATE INDEX IF NOT EXISTS room_names_room_id ON room_names(room_id);
|
||||
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 VARCHAR(150) PRIMARY KEY NOT NULL,
|
||||
|
@ -120,4 +120,4 @@ CREATE TABLE IF NOT EXISTS room_hosts(
|
|||
UNIQUE (room_id, host)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS room_hosts_room_id ON room_hosts (room_id);
|
||||
CREATE INDEX room_hosts_room_id ON room_hosts (room_id);
|
||||
|
|
|
@ -16,8 +16,8 @@ CREATE TABLE IF NOT EXISTS server_tls_certificates(
|
|||
server_name VARCHAR(150), -- Server name.
|
||||
fingerprint VARCHAR(150), -- Certificate fingerprint.
|
||||
from_server VARCHAR(150), -- Which key server the certificate was fetched from.
|
||||
ts_added_ms BIGINT UNSIGNED, -- When the certifcate was added.
|
||||
tls_certificate LONGBLOB, -- DER encoded x509 certificate.
|
||||
ts_added_ms BIGINT, -- When the certifcate was added.
|
||||
tls_certificate bytea, -- DER encoded x509 certificate.
|
||||
UNIQUE (server_name, fingerprint)
|
||||
);
|
||||
|
||||
|
@ -25,7 +25,7 @@ CREATE TABLE IF NOT EXISTS server_signature_keys(
|
|||
server_name VARCHAR(150), -- Server name.
|
||||
key_id VARCHAR(150), -- Key version.
|
||||
from_server VARCHAR(150), -- Which key server the key was fetched form.
|
||||
ts_added_ms BIGINT UNSIGNED, -- When the key was added.
|
||||
verify_key LONGBLOB, -- NACL verification key.
|
||||
ts_added_ms BIGINT, -- When the key was added.
|
||||
verify_key bytea, -- NACL verification key.
|
||||
UNIQUE (server_name, key_id)
|
||||
);
|
||||
|
|
|
@ -17,7 +17,7 @@ CREATE TABLE IF NOT EXISTS local_media_repository (
|
|||
media_id VARCHAR(150), -- The id used to refer to the media.
|
||||
media_type VARCHAR(150), -- The MIME-type of the media.
|
||||
media_length INTEGER, -- Length of the media in bytes.
|
||||
created_ts BIGINT UNSIGNED, -- When the content was uploaded in ms.
|
||||
created_ts BIGINT, -- When the content was uploaded in ms.
|
||||
upload_name VARCHAR(150), -- The name the media was uploaded with.
|
||||
user_id VARCHAR(150), -- The user who uploaded the file.
|
||||
UNIQUE (media_id)
|
||||
|
@ -35,14 +35,14 @@ CREATE TABLE IF NOT EXISTS local_media_repository_thumbnails (
|
|||
)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS local_media_repository_thumbnails_media_id
|
||||
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 VARCHAR(150), -- The remote HS the media came from.
|
||||
media_id VARCHAR(150), -- The id used to refer to the media on that server.
|
||||
media_type VARCHAR(150), -- The MIME-type of the media.
|
||||
created_ts BIGINT UNSIGNED, -- When the content was uploaded in ms.
|
||||
created_ts BIGINT, -- When the content was uploaded in ms.
|
||||
upload_name VARCHAR(150), -- The name the media was uploaded with.
|
||||
media_length INTEGER, -- Length of the media in bytes.
|
||||
filesystem_id VARCHAR(150), -- The name used to store the media on disk.
|
||||
|
|
|
@ -16,7 +16,7 @@ CREATE TABLE IF NOT EXISTS presence(
|
|||
user_id VARCHAR(150) NOT NULL,
|
||||
state VARCHAR(20),
|
||||
status_msg VARCHAR(150),
|
||||
mtime BIGINT UNSIGNED -- miliseconds since last state change
|
||||
mtime BIGINT -- miliseconds since last state change
|
||||
);
|
||||
|
||||
-- For each of /my/ users which possibly-remote users are allowed to see their
|
||||
|
|
|
@ -18,5 +18,5 @@ CREATE TABLE IF NOT EXISTS redactions (
|
|||
UNIQUE (event_id)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS redactions_event_id ON redactions (event_id);
|
||||
CREATE INDEX IF NOT EXISTS redactions_redacts ON redactions (redacts);
|
||||
CREATE INDEX redactions_event_id ON redactions (event_id);
|
||||
CREATE INDEX redactions_redacts ON redactions (redacts);
|
||||
|
|
|
@ -14,13 +14,13 @@
|
|||
*/
|
||||
|
||||
CREATE TABLE IF NOT EXISTS state_groups(
|
||||
id VARCHAR(20) PRIMARY KEY,
|
||||
id INTEGER PRIMARY KEY,
|
||||
room_id VARCHAR(150) NOT NULL,
|
||||
event_id VARCHAR(150) NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS state_groups_state(
|
||||
state_group VARCHAR(20) NOT NULL,
|
||||
state_group INTEGER NOT NULL,
|
||||
room_id VARCHAR(150) NOT NULL,
|
||||
type VARCHAR(150) NOT NULL,
|
||||
state_key VARCHAR(150) NOT NULL,
|
||||
|
@ -29,12 +29,12 @@ CREATE TABLE IF NOT EXISTS state_groups_state(
|
|||
|
||||
CREATE TABLE IF NOT EXISTS event_to_state_groups(
|
||||
event_id VARCHAR(150) NOT NULL,
|
||||
state_group VARCHAR(150) NOT NULL,
|
||||
state_group INTEGER NOT NULL,
|
||||
UNIQUE (event_id)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS state_groups_id ON state_groups(id);
|
||||
CREATE INDEX state_groups_id ON state_groups(id);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS state_groups_state_id ON state_groups_state(state_group);
|
||||
CREATE INDEX IF NOT EXISTS state_groups_state_tuple ON state_groups_state(room_id, type, state_key);
|
||||
CREATE INDEX IF NOT EXISTS event_to_state_groups_id ON event_to_state_groups(event_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);
|
||||
|
|
|
@ -16,14 +16,14 @@
|
|||
CREATE TABLE IF NOT EXISTS received_transactions(
|
||||
transaction_id VARCHAR(150),
|
||||
origin VARCHAR(150),
|
||||
ts BIGINT UNSIGNED,
|
||||
ts BIGINT,
|
||||
response_code INTEGER,
|
||||
response_json LONGBLOB,
|
||||
has_been_referenced BOOL default 0, -- Whether thishas been referenced by a prev_tx
|
||||
response_json bytea,
|
||||
has_been_referenced SMALLINT DEFAULT 0, -- Whether thishas been referenced by a prev_tx
|
||||
UNIQUE (transaction_id, origin)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS transactions_have_ref ON received_transactions(origin, has_been_referenced);-- WHERE has_been_referenced = 0;
|
||||
CREATE INDEX transactions_have_ref ON received_transactions(origin, has_been_referenced);-- WHERE has_been_referenced = 0;
|
||||
|
||||
|
||||
-- Stores what transactions we've sent, what their response was (if we got one) and whether we have
|
||||
|
@ -33,15 +33,15 @@ CREATE TABLE IF NOT EXISTS sent_transactions(
|
|||
transaction_id VARCHAR(150),
|
||||
destination VARCHAR(150),
|
||||
response_code INTEGER DEFAULT 0,
|
||||
response_json LONGBLOB,
|
||||
ts BIGINT UNSIGNED
|
||||
response_json bytea,
|
||||
ts BIGINT
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS sent_transaction_dest ON sent_transactions(destination);
|
||||
CREATE INDEX IF NOT EXISTS sent_transaction_txn_id ON sent_transactions(transaction_id);
|
||||
CREATE INDEX sent_transaction_dest ON sent_transactions(destination);
|
||||
CREATE INDEX sent_transaction_txn_id ON sent_transactions(transaction_id);
|
||||
-- So that we can do an efficient look up of all transactions that have yet to be successfully
|
||||
-- sent.
|
||||
CREATE INDEX IF NOT EXISTS sent_transaction_sent ON sent_transactions(response_code);
|
||||
CREATE INDEX sent_transaction_sent ON sent_transactions(response_code);
|
||||
|
||||
|
||||
-- For sent transactions only.
|
||||
|
@ -52,12 +52,12 @@ CREATE TABLE IF NOT EXISTS transaction_id_to_pdu(
|
|||
pdu_origin VARCHAR(150)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS transaction_id_to_pdu_tx ON transaction_id_to_pdu(transaction_id, destination);
|
||||
CREATE INDEX IF NOT EXISTS transaction_id_to_pdu_dest ON transaction_id_to_pdu(destination);
|
||||
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 VARCHAR(150) PRIMARY KEY,
|
||||
retry_last_ts BIGINT UNSIGNED,
|
||||
retry_last_ts BIGINT,
|
||||
retry_interval INTEGER
|
||||
);
|
||||
|
|
|
@ -16,8 +16,8 @@ CREATE TABLE IF NOT EXISTS users(
|
|||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
name VARCHAR(150),
|
||||
password_hash VARCHAR(150),
|
||||
creation_ts BIGINT UNSIGNED,
|
||||
admin BOOL DEFAULT 0 NOT NULL,
|
||||
creation_ts BIGINT,
|
||||
admin SMALLINT DEFAULT 0 NOT NULL,
|
||||
UNIQUE(name)
|
||||
);
|
||||
|
||||
|
@ -26,7 +26,7 @@ CREATE TABLE IF NOT EXISTS access_tokens(
|
|||
user_id VARCHAR(150) NOT NULL,
|
||||
device_id VARCHAR(150),
|
||||
token VARCHAR(150) NOT NULL,
|
||||
last_used BIGINT UNSIGNED,
|
||||
last_used BIGINT,
|
||||
UNIQUE(token)
|
||||
);
|
||||
|
||||
|
@ -36,8 +36,8 @@ CREATE TABLE IF NOT EXISTS user_ips (
|
|||
device_id VARCHAR(150),
|
||||
ip VARCHAR(150) NOT NULL,
|
||||
user_agent VARCHAR(150) NOT NULL,
|
||||
last_seen BIGINT UNSIGNED NOT NULL,
|
||||
last_seen BIGINT NOT NULL,
|
||||
UNIQUE (user, access_token, ip, user_agent)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS user_ips_user ON user_ips(user);
|
||||
CREATE INDEX user_ips_user ON user_ips(user);
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
*/
|
||||
|
||||
CREATE TABLE IF NOT EXISTS events(
|
||||
stream_ordering BIGINT PRIMARY KEY,
|
||||
stream_ordering INTEGER PRIMARY KEY,
|
||||
topological_ordering BIGINT NOT NULL,
|
||||
event_id VARCHAR(150) NOT NULL,
|
||||
type VARCHAR(150) NOT NULL,
|
||||
|
@ -31,6 +31,9 @@ CREATE INDEX events_stream_ordering ON events (stream_ordering);
|
|||
CREATE INDEX events_topological_ordering ON events (topological_ordering);
|
||||
CREATE INDEX events_order ON events (topological_ordering, stream_ordering);
|
||||
CREATE INDEX events_room_id ON events (room_id);
|
||||
CREATE INDEX events_order_room ON events (
|
||||
room_id, topological_ordering, stream_ordering
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS event_json(
|
||||
|
|
|
@ -20,7 +20,7 @@ CREATE TABLE IF NOT EXISTS state_groups(
|
|||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS state_groups_state(
|
||||
state_group VARCHAR(20) NOT NULL,
|
||||
state_group BIGINT NOT NULL,
|
||||
room_id VARCHAR(150) NOT NULL,
|
||||
type VARCHAR(150) NOT NULL,
|
||||
state_key VARCHAR(150) NOT NULL,
|
||||
|
@ -29,7 +29,7 @@ CREATE TABLE IF NOT EXISTS state_groups_state(
|
|||
|
||||
CREATE TABLE IF NOT EXISTS event_to_state_groups(
|
||||
event_id VARCHAR(150) NOT NULL,
|
||||
state_group VARCHAR(150) NOT NULL,
|
||||
state_group BIGINT NOT NULL,
|
||||
UNIQUE (event_id)
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in a new issue