Fix up schemas to work with mariadb
This commit is contained in:
parent
89036579ed
commit
fae059cc18
|
@ -18,11 +18,11 @@ CREATE TABLE IF NOT EXISTS rejections(
|
||||||
reason VARCHAR(255) NOT NULL,
|
reason VARCHAR(255) NOT NULL,
|
||||||
last_check VARCHAR(255) NOT NULL,
|
last_check VARCHAR(255) NOT NULL,
|
||||||
UNIQUE (event_id)
|
UNIQUE (event_id)
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
||||||
-- Push notification endpoints that users have configured
|
-- Push notification endpoints that users have configured
|
||||||
CREATE TABLE IF NOT EXISTS pushers (
|
CREATE TABLE IF NOT EXISTS pushers (
|
||||||
id INTEGER PRIMARY KEY,
|
id BIGINT PRIMARY KEY,
|
||||||
user_name VARCHAR(255) NOT NULL,
|
user_name VARCHAR(255) NOT NULL,
|
||||||
profile_tag VARCHAR(32) NOT NULL,
|
profile_tag VARCHAR(32) NOT NULL,
|
||||||
kind VARCHAR(8) NOT NULL,
|
kind VARCHAR(8) NOT NULL,
|
||||||
|
@ -37,10 +37,10 @@ CREATE TABLE IF NOT EXISTS pushers (
|
||||||
last_success BIGINT,
|
last_success BIGINT,
|
||||||
failing_since BIGINT,
|
failing_since BIGINT,
|
||||||
UNIQUE (app_id, pushkey)
|
UNIQUE (app_id, pushkey)
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS push_rules (
|
CREATE TABLE IF NOT EXISTS push_rules (
|
||||||
id INTEGER PRIMARY KEY,
|
id BIGINT PRIMARY KEY,
|
||||||
user_name VARCHAR(255) NOT NULL,
|
user_name VARCHAR(255) NOT NULL,
|
||||||
rule_id VARCHAR(255) NOT NULL,
|
rule_id VARCHAR(255) NOT NULL,
|
||||||
priority_class TINYINT NOT NULL,
|
priority_class TINYINT NOT NULL,
|
||||||
|
@ -48,16 +48,16 @@ CREATE TABLE IF NOT EXISTS push_rules (
|
||||||
conditions VARCHAR(255) NOT NULL,
|
conditions VARCHAR(255) NOT NULL,
|
||||||
actions VARCHAR(255) NOT NULL,
|
actions VARCHAR(255) NOT NULL,
|
||||||
UNIQUE(user_name, rule_id)
|
UNIQUE(user_name, rule_id)
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS push_rules_user_name on push_rules (user_name);
|
CREATE INDEX IF NOT EXISTS push_rules_user_name on push_rules (user_name);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS user_filters(
|
CREATE TABLE IF NOT EXISTS user_filters(
|
||||||
user_id VARCHAR(255),
|
user_id VARCHAR(255),
|
||||||
filter_id INTEGER,
|
filter_id BIGINT,
|
||||||
filter_json BLOB
|
filter_json BLOB
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS user_filters_by_user_id_filter_id ON user_filters(
|
CREATE INDEX IF NOT EXISTS user_filters_by_user_id_filter_id ON user_filters(
|
||||||
user_id, filter_id
|
user_id, filter_id
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
|
@ -14,18 +14,18 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS application_services(
|
CREATE TABLE IF NOT EXISTS application_services(
|
||||||
id INTEGER PRIMARY KEY,
|
id BIGINT PRIMARY KEY,
|
||||||
url VARCHAR(255),
|
url VARCHAR(255),
|
||||||
token VARCHAR(255),
|
token VARCHAR(255),
|
||||||
hs_token VARCHAR(255),
|
hs_token VARCHAR(255),
|
||||||
sender VARCHAR(255),
|
sender VARCHAR(255),
|
||||||
UNIQUE(token)
|
UNIQUE(token)
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS application_services_regex(
|
CREATE TABLE IF NOT EXISTS application_services_regex(
|
||||||
id INTEGER PRIMARY KEY,
|
id BIGINT PRIMARY KEY,
|
||||||
as_id INTEGER NOT NULL,
|
as_id BIGINT NOT NULL,
|
||||||
namespace INTEGER, /* enum[room_id|room_alias|user_id] */
|
namespace INTEGER, /* enum[room_id|room_alias|user_id] */
|
||||||
regex VARCHAR(255),
|
regex VARCHAR(255),
|
||||||
FOREIGN KEY(as_id) REFERENCES application_services(id)
|
FOREIGN KEY(as_id) REFERENCES application_services(id)
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
CREATE TABLE IF NOT EXISTS push_rules_enable (
|
CREATE TABLE IF NOT EXISTS push_rules_enable (
|
||||||
id INTEGER PRIMARY KEY,
|
id BIGINT PRIMARY KEY,
|
||||||
user_name VARCHAR(255) NOT NULL,
|
user_name VARCHAR(255) NOT NULL,
|
||||||
rule_id VARCHAR(255) NOT NULL,
|
rule_id VARCHAR(255) NOT NULL,
|
||||||
enabled TINYINT,
|
enabled TINYINT,
|
||||||
UNIQUE(user_name, rule_id)
|
UNIQUE(user_name, rule_id)
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS push_rules_enable_user_name on push_rules_enable (user_name);
|
CREATE INDEX IF NOT EXISTS push_rules_enable_user_name on push_rules_enable (user_name);
|
||||||
|
|
|
@ -17,7 +17,7 @@ CREATE TABLE IF NOT EXISTS event_forward_extremities(
|
||||||
event_id VARCHAR(255) NOT NULL,
|
event_id VARCHAR(255) NOT NULL,
|
||||||
room_id VARCHAR(255) NOT NULL,
|
room_id VARCHAR(255) NOT NULL,
|
||||||
UNIQUE (event_id, room_id)
|
UNIQUE (event_id, room_id)
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS ev_extrem_room ON event_forward_extremities(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 IF NOT EXISTS ev_extrem_id ON event_forward_extremities(event_id);
|
||||||
|
@ -27,7 +27,7 @@ CREATE TABLE IF NOT EXISTS event_backward_extremities(
|
||||||
event_id VARCHAR(255) NOT NULL,
|
event_id VARCHAR(255) NOT NULL,
|
||||||
room_id VARCHAR(255) NOT NULL,
|
room_id VARCHAR(255) NOT NULL,
|
||||||
UNIQUE (event_id, room_id)
|
UNIQUE (event_id, room_id)
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS ev_b_extrem_room ON event_backward_extremities(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 IF NOT EXISTS ev_b_extrem_id ON event_backward_extremities(event_id);
|
||||||
|
@ -39,7 +39,7 @@ CREATE TABLE IF NOT EXISTS event_edges(
|
||||||
room_id VARCHAR(255) NOT NULL,
|
room_id VARCHAR(255) NOT NULL,
|
||||||
is_state BOOL NOT NULL,
|
is_state BOOL NOT NULL,
|
||||||
UNIQUE (event_id, prev_event_id, room_id, is_state)
|
UNIQUE (event_id, prev_event_id, room_id, is_state)
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS ev_edges_id ON event_edges(event_id);
|
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 IF NOT EXISTS ev_edges_prev_id ON event_edges(prev_event_id);
|
||||||
|
@ -49,7 +49,7 @@ CREATE TABLE IF NOT EXISTS room_depth(
|
||||||
room_id VARCHAR(255) NOT NULL,
|
room_id VARCHAR(255) NOT NULL,
|
||||||
min_depth INTEGER NOT NULL,
|
min_depth INTEGER NOT NULL,
|
||||||
UNIQUE (room_id)
|
UNIQUE (room_id)
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS room_depth_room ON room_depth(room_id);
|
CREATE INDEX IF NOT EXISTS room_depth_room ON room_depth(room_id);
|
||||||
|
|
||||||
|
@ -57,9 +57,9 @@ CREATE INDEX IF NOT EXISTS room_depth_room ON room_depth(room_id);
|
||||||
create TABLE IF NOT EXISTS event_destinations(
|
create TABLE IF NOT EXISTS event_destinations(
|
||||||
event_id VARCHAR(255) NOT NULL,
|
event_id VARCHAR(255) NOT NULL,
|
||||||
destination VARCHAR(255) NOT NULL,
|
destination VARCHAR(255) NOT NULL,
|
||||||
delivered_ts INTEGER DEFAULT 0, -- or 0 if not delivered
|
delivered_ts BIGINT DEFAULT 0, -- or 0 if not delivered
|
||||||
UNIQUE (event_id, destination)
|
UNIQUE (event_id, destination)
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS event_destinations_id ON event_destinations(event_id);
|
CREATE INDEX IF NOT EXISTS event_destinations_id ON event_destinations(event_id);
|
||||||
|
|
||||||
|
@ -70,11 +70,11 @@ CREATE TABLE IF NOT EXISTS state_forward_extremities(
|
||||||
type VARCHAR(255) NOT NULL,
|
type VARCHAR(255) NOT NULL,
|
||||||
state_key VARCHAR(255) NOT NULL,
|
state_key VARCHAR(255) NOT NULL,
|
||||||
UNIQUE (event_id, room_id)
|
UNIQUE (event_id, room_id)
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS st_extrem_keys ON state_forward_extremities(
|
CREATE INDEX IF NOT EXISTS st_extrem_keys ON state_forward_extremities(
|
||||||
room_id, type, state_key
|
room_id, type, state_key
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
CREATE INDEX IF NOT EXISTS st_extrem_id ON state_forward_extremities(event_id);
|
CREATE INDEX IF NOT EXISTS st_extrem_id ON state_forward_extremities(event_id);
|
||||||
|
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ CREATE TABLE IF NOT EXISTS event_auth(
|
||||||
auth_id VARCHAR(255) NOT NULL,
|
auth_id VARCHAR(255) NOT NULL,
|
||||||
room_id VARCHAR(255) NOT NULL,
|
room_id VARCHAR(255) NOT NULL,
|
||||||
UNIQUE (event_id, auth_id, room_id)
|
UNIQUE (event_id, auth_id, room_id)
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS evauth_edges_id ON event_auth(event_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 IF NOT EXISTS evauth_edges_auth_id ON event_auth(auth_id);
|
||||||
|
|
|
@ -18,7 +18,7 @@ CREATE TABLE IF NOT EXISTS event_content_hashes (
|
||||||
algorithm VARCHAR(255),
|
algorithm VARCHAR(255),
|
||||||
hash BLOB,
|
hash BLOB,
|
||||||
UNIQUE (event_id, algorithm)
|
UNIQUE (event_id, algorithm)
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS event_content_hashes_id ON event_content_hashes(event_id);
|
CREATE INDEX IF NOT EXISTS event_content_hashes_id ON event_content_hashes(event_id);
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ CREATE TABLE IF NOT EXISTS event_reference_hashes (
|
||||||
algorithm VARCHAR(255),
|
algorithm VARCHAR(255),
|
||||||
hash BLOB,
|
hash BLOB,
|
||||||
UNIQUE (event_id, algorithm)
|
UNIQUE (event_id, algorithm)
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS event_reference_hashes_id ON event_reference_hashes(event_id);
|
CREATE INDEX IF NOT EXISTS event_reference_hashes_id ON event_reference_hashes(event_id);
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ CREATE TABLE IF NOT EXISTS event_signatures (
|
||||||
key_id VARCHAR(255),
|
key_id VARCHAR(255),
|
||||||
signature BLOB,
|
signature BLOB,
|
||||||
UNIQUE (event_id, signature_name, key_id)
|
UNIQUE (event_id, signature_name, key_id)
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS event_signatures_id ON event_signatures(event_id);
|
CREATE INDEX IF NOT EXISTS event_signatures_id ON event_signatures(event_id);
|
||||||
|
|
||||||
|
@ -50,6 +50,6 @@ CREATE TABLE IF NOT EXISTS event_edge_hashes(
|
||||||
algorithm VARCHAR(255),
|
algorithm VARCHAR(255),
|
||||||
hash BLOB,
|
hash BLOB,
|
||||||
UNIQUE (event_id, prev_event_id, algorithm)
|
UNIQUE (event_id, prev_event_id, algorithm)
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS event_edge_hashes_id ON event_edge_hashes(event_id);
|
CREATE INDEX IF NOT EXISTS event_edge_hashes_id ON event_edge_hashes(event_id);
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS events(
|
CREATE TABLE IF NOT EXISTS events(
|
||||||
stream_ordering INTEGER PRIMARY KEY,
|
stream_ordering BIGINT PRIMARY KEY,
|
||||||
topological_ordering INTEGER NOT NULL,
|
topological_ordering BIGINT NOT NULL,
|
||||||
event_id VARCHAR(255) NOT NULL,
|
event_id VARCHAR(255) NOT NULL,
|
||||||
type VARCHAR(255) NOT NULL,
|
type VARCHAR(255) NOT NULL,
|
||||||
room_id VARCHAR(255) NOT NULL,
|
room_id VARCHAR(255) NOT NULL,
|
||||||
|
@ -23,9 +23,9 @@ CREATE TABLE IF NOT EXISTS events(
|
||||||
unrecognized_keys BLOB,
|
unrecognized_keys BLOB,
|
||||||
processed BOOL NOT NULL,
|
processed BOOL NOT NULL,
|
||||||
outlier BOOL NOT NULL,
|
outlier BOOL NOT NULL,
|
||||||
depth INTEGER DEFAULT 0 NOT NULL,
|
depth BIGINT DEFAULT 0 NOT NULL,
|
||||||
UNIQUE (event_id)
|
UNIQUE (event_id)
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS events_event_id ON events (event_id);
|
CREATE INDEX IF NOT EXISTS events_event_id ON events (event_id);
|
||||||
CREATE INDEX IF NOT EXISTS events_stream_ordering ON events (stream_ordering);
|
CREATE INDEX IF NOT EXISTS events_stream_ordering ON events (stream_ordering);
|
||||||
|
@ -39,19 +39,19 @@ CREATE TABLE IF NOT EXISTS event_json(
|
||||||
internal_metadata BLOB NOT NULL,
|
internal_metadata BLOB NOT NULL,
|
||||||
json BLOB NOT NULL,
|
json BLOB NOT NULL,
|
||||||
UNIQUE (event_id)
|
UNIQUE (event_id)
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS event_json_room_id ON event_json(room_id);
|
CREATE INDEX IF NOT EXISTS event_json_room_id ON event_json(room_id);
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE state_events(
|
CREATE TABLE IF NOT EXISTS state_events(
|
||||||
event_id VARCHAR(255) NOT NULL,
|
event_id VARCHAR(255) NOT NULL,
|
||||||
room_id VARCHAR(255) NOT NULL,
|
room_id VARCHAR(255) NOT NULL,
|
||||||
type VARCHAR(255) NOT NULL,
|
type VARCHAR(255) NOT NULL,
|
||||||
state_key VARCHAR(255) NOT NULL,
|
state_key VARCHAR(255) NOT NULL,
|
||||||
prev_state VARCHAR(255),
|
prev_state VARCHAR(255),
|
||||||
UNIQUE (event_id)
|
UNIQUE (event_id)
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS state_events_room_id ON state_events (room_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_type ON state_events (type);
|
||||||
|
@ -65,7 +65,7 @@ CREATE TABLE IF NOT EXISTS current_state_events(
|
||||||
state_key VARCHAR(255) NOT NULL,
|
state_key VARCHAR(255) NOT NULL,
|
||||||
UNIQUE (event_id),
|
UNIQUE (event_id),
|
||||||
UNIQUE (room_id, type, state_key)
|
UNIQUE (room_id, type, state_key)
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS current_state_events_room_id ON current_state_events (room_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_type ON current_state_events (type);
|
||||||
|
@ -78,7 +78,7 @@ CREATE TABLE IF NOT EXISTS room_memberships(
|
||||||
room_id VARCHAR(255) NOT NULL,
|
room_id VARCHAR(255) NOT NULL,
|
||||||
membership VARCHAR(255) NOT NULL,
|
membership VARCHAR(255) NOT NULL,
|
||||||
UNIQUE (event_id)
|
UNIQUE (event_id)
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS room_memberships_room_id ON room_memberships (room_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 IF NOT EXISTS room_memberships_user_id ON room_memberships (user_id);
|
||||||
|
@ -90,14 +90,14 @@ CREATE TABLE IF NOT EXISTS feedback(
|
||||||
sender VARCHAR(255),
|
sender VARCHAR(255),
|
||||||
room_id VARCHAR(255),
|
room_id VARCHAR(255),
|
||||||
UNIQUE (event_id)
|
UNIQUE (event_id)
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS topics(
|
CREATE TABLE IF NOT EXISTS topics(
|
||||||
event_id VARCHAR(255) NOT NULL,
|
event_id VARCHAR(255) NOT NULL,
|
||||||
room_id VARCHAR(255) NOT NULL,
|
room_id VARCHAR(255) NOT NULL,
|
||||||
topic VARCHAR(255) NOT NULL,
|
topic VARCHAR(255) NOT NULL,
|
||||||
UNIQUE (event_id)
|
UNIQUE (event_id)
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS topics_room_id ON topics(room_id);
|
CREATE INDEX IF NOT EXISTS topics_room_id ON topics(room_id);
|
||||||
|
|
||||||
|
@ -112,14 +112,14 @@ CREATE INDEX IF NOT EXISTS room_names_room_id ON room_names(room_id);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS rooms(
|
CREATE TABLE IF NOT EXISTS rooms(
|
||||||
room_id VARCHAR(255) PRIMARY KEY NOT NULL,
|
room_id VARCHAR(255) PRIMARY KEY NOT NULL,
|
||||||
is_public INTEGER,
|
is_public BOOL,
|
||||||
creator VARCHAR(255)
|
creator VARCHAR(255)
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS room_hosts(
|
CREATE TABLE IF NOT EXISTS room_hosts(
|
||||||
room_id VARCHAR(255) NOT NULL,
|
room_id VARCHAR(255) NOT NULL,
|
||||||
host VARCHAR(255) NOT NULL,
|
host VARCHAR(255) NOT NULL,
|
||||||
UNIQUE (room_id, host)
|
UNIQUE (room_id, host)
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS room_hosts_room_id ON room_hosts (room_id);
|
CREATE INDEX IF NOT EXISTS room_hosts_room_id ON room_hosts (room_id);
|
||||||
|
|
|
@ -16,16 +16,16 @@ CREATE TABLE IF NOT EXISTS server_tls_certificates(
|
||||||
server_name VARCHAR(255), -- Server name.
|
server_name VARCHAR(255), -- Server name.
|
||||||
fingerprint VARCHAR(255), -- Certificate fingerprint.
|
fingerprint VARCHAR(255), -- Certificate fingerprint.
|
||||||
from_server VARCHAR(255), -- Which key server the certificate was fetched from.
|
from_server VARCHAR(255), -- Which key server the certificate was fetched from.
|
||||||
ts_added_ms INTEGER, -- When the certifcate was added.
|
ts_added_ms BIGINT, -- When the certifcate was added.
|
||||||
tls_certificate BLOB, -- DER encoded x509 certificate.
|
tls_certificate BLOB, -- DER encoded x509 certificate.
|
||||||
UNIQUE (server_name, fingerprint)
|
UNIQUE (server_name, fingerprint)
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS server_signature_keys(
|
CREATE TABLE IF NOT EXISTS server_signature_keys(
|
||||||
server_name VARCHAR(255), -- Server name.
|
server_name VARCHAR(255), -- Server name.
|
||||||
key_id VARCHAR(255), -- Key version.
|
key_id VARCHAR(255), -- Key version.
|
||||||
from_server VARCHAR(255), -- Which key server the key was fetched form.
|
from_server VARCHAR(255), -- Which key server the key was fetched form.
|
||||||
ts_added_ms INTEGER, -- When the key was added.
|
ts_added_ms BIGINT, -- When the key was added.
|
||||||
verify_key BLOB, -- NACL verification key.
|
verify_key BLOB, -- NACL verification key.
|
||||||
UNIQUE (server_name, key_id)
|
UNIQUE (server_name, key_id)
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
|
@ -17,11 +17,11 @@ CREATE TABLE IF NOT EXISTS local_media_repository (
|
||||||
media_id VARCHAR(255), -- The id used to refer to the media.
|
media_id VARCHAR(255), -- The id used to refer to the media.
|
||||||
media_type VARCHAR(255), -- The MIME-type of the media.
|
media_type VARCHAR(255), -- The MIME-type of the media.
|
||||||
media_length INTEGER, -- Length of the media in bytes.
|
media_length INTEGER, -- Length of the media in bytes.
|
||||||
created_ts INTEGER, -- When the content was uploaded in ms.
|
created_ts BIGINT, -- When the content was uploaded in ms.
|
||||||
upload_name VARCHAR(255), -- The name the media was uploaded with.
|
upload_name VARCHAR(255), -- The name the media was uploaded with.
|
||||||
user_id VARCHAR(255), -- The user who uploaded the file.
|
user_id VARCHAR(255), -- The user who uploaded the file.
|
||||||
UNIQUE (media_id)
|
UNIQUE (media_id)
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS local_media_repository_thumbnails (
|
CREATE TABLE IF NOT EXISTS local_media_repository_thumbnails (
|
||||||
media_id VARCHAR(255), -- The id used to refer to the media.
|
media_id VARCHAR(255), -- The id used to refer to the media.
|
||||||
|
@ -33,7 +33,7 @@ CREATE TABLE IF NOT EXISTS local_media_repository_thumbnails (
|
||||||
UNIQUE (
|
UNIQUE (
|
||||||
media_id, thumbnail_width, thumbnail_height, thumbnail_type
|
media_id, thumbnail_width, thumbnail_height, thumbnail_type
|
||||||
)
|
)
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS local_media_repository_thumbnails_media_id
|
CREATE INDEX IF NOT EXISTS local_media_repository_thumbnails_media_id
|
||||||
ON local_media_repository_thumbnails (media_id);
|
ON local_media_repository_thumbnails (media_id);
|
||||||
|
@ -42,12 +42,12 @@ CREATE TABLE IF NOT EXISTS remote_media_cache (
|
||||||
media_origin VARCHAR(255), -- The remote HS the media came from.
|
media_origin VARCHAR(255), -- The remote HS the media came from.
|
||||||
media_id VARCHAR(255), -- The id used to refer to the media on that server.
|
media_id VARCHAR(255), -- The id used to refer to the media on that server.
|
||||||
media_type VARCHAR(255), -- The MIME-type of the media.
|
media_type VARCHAR(255), -- The MIME-type of the media.
|
||||||
created_ts INTEGER, -- When the content was uploaded in ms.
|
created_ts BIGINT, -- When the content was uploaded in ms.
|
||||||
upload_name VARCHAR(255), -- The name the media was uploaded with.
|
upload_name VARCHAR(255), -- The name the media was uploaded with.
|
||||||
media_length INTEGER, -- Length of the media in bytes.
|
media_length INTEGER, -- Length of the media in bytes.
|
||||||
filesystem_id VARCHAR(255), -- The name used to store the media on disk.
|
filesystem_id VARCHAR(255), -- The name used to store the media on disk.
|
||||||
UNIQUE (media_origin, media_id)
|
UNIQUE (media_origin, media_id)
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS remote_media_cache_thumbnails (
|
CREATE TABLE IF NOT EXISTS remote_media_cache_thumbnails (
|
||||||
media_origin VARCHAR(255), -- The remote HS the media came from.
|
media_origin VARCHAR(255), -- The remote HS the media came from.
|
||||||
|
@ -62,7 +62,7 @@ CREATE TABLE IF NOT EXISTS remote_media_cache_thumbnails (
|
||||||
media_origin, media_id, thumbnail_width, thumbnail_height,
|
media_origin, media_id, thumbnail_width, thumbnail_height,
|
||||||
thumbnail_type
|
thumbnail_type
|
||||||
)
|
)
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS remote_media_cache_thumbnails_media_id
|
CREATE INDEX IF NOT EXISTS remote_media_cache_thumbnails_media_id
|
||||||
ON local_media_repository_thumbnails (media_id);
|
ON local_media_repository_thumbnails (media_id);
|
||||||
|
|
|
@ -14,11 +14,11 @@
|
||||||
*/
|
*/
|
||||||
CREATE TABLE IF NOT EXISTS presence(
|
CREATE TABLE IF NOT EXISTS presence(
|
||||||
user_id VARCHAR(255) NOT NULL,
|
user_id VARCHAR(255) NOT NULL,
|
||||||
state INTEGER,
|
state VARCHAR(20),
|
||||||
status_msg VARCHAR(255),
|
status_msg VARCHAR(255),
|
||||||
mtime INTEGER, -- miliseconds since last state change
|
mtime BIGINT, -- miliseconds since last state change
|
||||||
UNIQUE(user_id)
|
UNIQUE(user_id)
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
||||||
-- For each of /my/ users which possibly-remote users are allowed to see their
|
-- For each of /my/ users which possibly-remote users are allowed to see their
|
||||||
-- presence state
|
-- presence state
|
||||||
|
@ -26,7 +26,7 @@ CREATE TABLE IF NOT EXISTS presence_allow_inbound(
|
||||||
observed_user_id VARCHAR(255) NOT NULL,
|
observed_user_id VARCHAR(255) NOT NULL,
|
||||||
observer_user_id VARCHAR(255), -- a UserID,
|
observer_user_id VARCHAR(255), -- a UserID,
|
||||||
UNIQUE(observed_user_id)
|
UNIQUE(observed_user_id)
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
||||||
-- For each of /my/ users (watcher), which possibly-remote users are they
|
-- For each of /my/ users (watcher), which possibly-remote users are they
|
||||||
-- watching?
|
-- watching?
|
||||||
|
@ -35,4 +35,4 @@ CREATE TABLE IF NOT EXISTS presence_list(
|
||||||
observed_user_id VARCHAR(255), -- a UserID,
|
observed_user_id VARCHAR(255), -- a UserID,
|
||||||
accepted BOOLEAN,
|
accepted BOOLEAN,
|
||||||
UNIQUE(user_id)
|
UNIQUE(user_id)
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
|
@ -17,4 +17,4 @@ CREATE TABLE IF NOT EXISTS profiles(
|
||||||
displayname VARCHAR(255),
|
displayname VARCHAR(255),
|
||||||
avatar_url VARCHAR(255),
|
avatar_url VARCHAR(255),
|
||||||
UNIQUE(user_id)
|
UNIQUE(user_id)
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
|
@ -16,7 +16,7 @@ CREATE TABLE IF NOT EXISTS redactions (
|
||||||
event_id VARCHAR(255) NOT NULL,
|
event_id VARCHAR(255) NOT NULL,
|
||||||
redacts VARCHAR(255) NOT NULL,
|
redacts VARCHAR(255) NOT NULL,
|
||||||
UNIQUE (event_id)
|
UNIQUE (event_id)
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS redactions_event_id ON redactions (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 IF NOT EXISTS redactions_redacts ON redactions (redacts);
|
||||||
|
|
|
@ -17,9 +17,9 @@ CREATE TABLE IF NOT EXISTS room_aliases(
|
||||||
room_alias VARCHAR(255) NOT NULL,
|
room_alias VARCHAR(255) NOT NULL,
|
||||||
room_id VARCHAR(255) NOT NULL,
|
room_id VARCHAR(255) NOT NULL,
|
||||||
UNIQUE (room_alias)
|
UNIQUE (room_alias)
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS room_alias_servers(
|
CREATE TABLE IF NOT EXISTS room_alias_servers(
|
||||||
room_alias VARCHAR(255) NOT NULL,
|
room_alias VARCHAR(255) NOT NULL,
|
||||||
server VARCHAR(255) NOT NULL
|
server VARCHAR(255) NOT NULL
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
|
@ -14,24 +14,24 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS state_groups(
|
CREATE TABLE IF NOT EXISTS state_groups(
|
||||||
id INTEGER PRIMARY KEY,
|
id VARCHAR(20) PRIMARY KEY,
|
||||||
room_id VARCHAR(255) NOT NULL,
|
room_id VARCHAR(255) NOT NULL,
|
||||||
event_id VARCHAR(255) NOT NULL
|
event_id VARCHAR(255) NOT NULL
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS state_groups_state(
|
CREATE TABLE IF NOT EXISTS state_groups_state(
|
||||||
state_group INTEGER NOT NULL,
|
state_group VARCHAR(20) NOT NULL,
|
||||||
room_id VARCHAR(255) NOT NULL,
|
room_id VARCHAR(255) NOT NULL,
|
||||||
type VARCHAR(255) NOT NULL,
|
type VARCHAR(255) NOT NULL,
|
||||||
state_key VARCHAR(255) NOT NULL,
|
state_key VARCHAR(255) NOT NULL,
|
||||||
event_id VARCHAR(255) NOT NULL
|
event_id VARCHAR(255) NOT NULL
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS event_to_state_groups(
|
CREATE TABLE IF NOT EXISTS event_to_state_groups(
|
||||||
event_id VARCHAR(255) NOT NULL,
|
event_id VARCHAR(255) NOT NULL,
|
||||||
state_group INTEGER NOT NULL,
|
state_group VARCHAR(255) NOT NULL,
|
||||||
UNIQUE (event_id)
|
UNIQUE (event_id)
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS state_groups_id ON state_groups(id);
|
CREATE INDEX IF NOT EXISTS state_groups_id ON state_groups(id);
|
||||||
|
|
||||||
|
|
|
@ -16,12 +16,12 @@
|
||||||
CREATE TABLE IF NOT EXISTS received_transactions(
|
CREATE TABLE IF NOT EXISTS received_transactions(
|
||||||
transaction_id VARCHAR(255),
|
transaction_id VARCHAR(255),
|
||||||
origin VARCHAR(255),
|
origin VARCHAR(255),
|
||||||
ts INTEGER,
|
ts BIGINT,
|
||||||
response_code INTEGER,
|
response_code INTEGER,
|
||||||
response_json BLOB,
|
response_json BLOB,
|
||||||
has_been_referenced BOOL default 0, -- Whether thishas been referenced by a prev_tx
|
has_been_referenced BOOL default 0, -- Whether thishas been referenced by a prev_tx
|
||||||
UNIQUE (transaction_id, origin)
|
UNIQUE (transaction_id, origin)
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS transactions_have_ref ON received_transactions(origin, has_been_referenced);-- WHERE has_been_referenced = 0;
|
CREATE INDEX IF NOT EXISTS transactions_have_ref ON received_transactions(origin, has_been_referenced);-- WHERE has_been_referenced = 0;
|
||||||
|
|
||||||
|
@ -29,13 +29,13 @@ CREATE INDEX IF NOT EXISTS transactions_have_ref ON received_transactions(origin
|
||||||
-- Stores what transactions we've sent, what their response was (if we got one) and whether we have
|
-- Stores what transactions we've sent, what their response was (if we got one) and whether we have
|
||||||
-- since referenced the transaction in another outgoing transaction
|
-- since referenced the transaction in another outgoing transaction
|
||||||
CREATE TABLE IF NOT EXISTS sent_transactions(
|
CREATE TABLE IF NOT EXISTS sent_transactions(
|
||||||
id INTEGER PRIMARY KEY, -- This is used to apply insertion ordering
|
id BIGINT PRIMARY KEY, -- This is used to apply insertion ordering
|
||||||
transaction_id VARCHAR(255),
|
transaction_id VARCHAR(255),
|
||||||
destination VARCHAR(255),
|
destination VARCHAR(255),
|
||||||
response_code INTEGER DEFAULT 0,
|
response_code INTEGER DEFAULT 0,
|
||||||
response_json BLOB,
|
response_json BLOB,
|
||||||
ts INTEGER
|
ts INTEGER
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS sent_transaction_dest ON sent_transactions(destination);
|
CREATE INDEX IF NOT EXISTS sent_transaction_dest ON sent_transactions(destination);
|
||||||
CREATE INDEX IF NOT EXISTS sent_transaction_dest_referenced ON sent_transactions(destination);
|
CREATE INDEX IF NOT EXISTS sent_transaction_dest_referenced ON sent_transactions(destination);
|
||||||
|
@ -52,13 +52,13 @@ CREATE TABLE IF NOT EXISTS transaction_id_to_pdu(
|
||||||
pdu_id VARCHAR(255),
|
pdu_id VARCHAR(255),
|
||||||
pdu_origin VARCHAR(255),
|
pdu_origin VARCHAR(255),
|
||||||
UNIQUE (transaction_id, destination)
|
UNIQUE (transaction_id, destination)
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS transaction_id_to_pdu_dest ON transaction_id_to_pdu(destination);
|
CREATE INDEX IF NOT EXISTS transaction_id_to_pdu_dest ON transaction_id_to_pdu(destination);
|
||||||
|
|
||||||
-- To track destination health
|
-- To track destination health
|
||||||
CREATE TABLE IF NOT EXISTS destinations(
|
CREATE TABLE IF NOT EXISTS destinations(
|
||||||
destination VARCHAR(255) PRIMARY KEY,
|
destination VARCHAR(255) PRIMARY KEY,
|
||||||
retry_last_ts INTEGER,
|
retry_last_ts BIGINT,
|
||||||
retry_interval INTEGER
|
retry_interval INTEGER
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
|
@ -13,23 +13,21 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
CREATE TABLE IF NOT EXISTS users(
|
CREATE TABLE IF NOT EXISTS users(
|
||||||
id INTEGER PRIMARY KEY,
|
|
||||||
name VARCHAR(255),
|
name VARCHAR(255),
|
||||||
password_hash VARBINARY(255),
|
password_hash VARBINARY(255),
|
||||||
creation_ts INTEGER,
|
creation_ts BIGINT,
|
||||||
admin BOOL DEFAULT 0 NOT NULL,
|
admin BOOL DEFAULT 0 NOT NULL,
|
||||||
UNIQUE(name)
|
UNIQUE(name)
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS access_tokens(
|
CREATE TABLE IF NOT EXISTS access_tokens(
|
||||||
id INTEGER PRIMARY KEY,
|
id INTEGER PRIMARY KEY AUTO_INCREMENT,
|
||||||
user_id INTEGER NOT NULL,
|
user_id VARCHAR(255) NOT NULL,
|
||||||
device_id VARCHAR(255),
|
device_id VARCHAR(255),
|
||||||
token VARCHAR(255) NOT NULL,
|
token VARCHAR(255) NOT NULL,
|
||||||
last_used INTEGER,
|
last_used BIGINT,
|
||||||
FOREIGN KEY(user_id) REFERENCES users(id),
|
|
||||||
UNIQUE(token)
|
UNIQUE(token)
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS user_ips (
|
CREATE TABLE IF NOT EXISTS user_ips (
|
||||||
user VARCHAR(255) NOT NULL,
|
user VARCHAR(255) NOT NULL,
|
||||||
|
@ -37,8 +35,8 @@ CREATE TABLE IF NOT EXISTS user_ips (
|
||||||
device_id VARCHAR(255),
|
device_id VARCHAR(255),
|
||||||
ip VARCHAR(255) NOT NULL,
|
ip VARCHAR(255) NOT NULL,
|
||||||
user_agent VARCHAR(255) NOT NULL,
|
user_agent VARCHAR(255) NOT NULL,
|
||||||
last_seen INTEGER NOT NULL,
|
last_seen BIGINT NOT NULL,
|
||||||
UNIQUE (user, access_token, ip, user_agent)
|
UNIQUE (user, access_token, ip, user_agent)
|
||||||
);
|
) ENGINE = INNODB;
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS user_ips_user ON user_ips(user);
|
CREATE INDEX IF NOT EXISTS user_ips_user ON user_ips(user);
|
||||||
|
|
Loading…
Reference in New Issue