Use TEXT instead of VARCHAR(n), since PostgreSQL treats them the same except for a limit

This commit is contained in:
Erik Johnston 2015-04-28 12:41:33 +01:00
parent af27b84ff7
commit 18f8247701
32 changed files with 289 additions and 289 deletions

View File

@ -14,16 +14,16 @@
*/ */
CREATE TABLE IF NOT EXISTS rejections( CREATE TABLE IF NOT EXISTS rejections(
event_id VARCHAR(150) NOT NULL, event_id TEXT NOT NULL,
reason VARCHAR(150) NOT NULL, reason TEXT NOT NULL,
last_check VARCHAR(150) NOT NULL, last_check TEXT NOT NULL,
UNIQUE (event_id) UNIQUE (event_id)
); );
-- 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 AUTOINCREMENT, id INTEGER PRIMARY KEY AUTOINCREMENT,
user_name VARCHAR(150) NOT NULL, user_name TEXT NOT NULL,
profile_tag VARCHAR(32) NOT NULL, profile_tag VARCHAR(32) NOT NULL,
kind VARCHAR(8) NOT NULL, kind VARCHAR(8) NOT NULL,
app_id VARCHAR(64) NOT NULL, app_id VARCHAR(64) NOT NULL,
@ -41,19 +41,19 @@ CREATE TABLE IF NOT EXISTS pushers (
CREATE TABLE IF NOT EXISTS push_rules ( CREATE TABLE IF NOT EXISTS push_rules (
id INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER PRIMARY KEY AUTOINCREMENT,
user_name VARCHAR(150) NOT NULL, user_name TEXT NOT NULL,
rule_id VARCHAR(150) NOT NULL, rule_id TEXT NOT NULL,
priority_class TINYINT NOT NULL, priority_class TINYINT NOT NULL,
priority INTEGER NOT NULL DEFAULT 0, priority INTEGER NOT NULL DEFAULT 0,
conditions VARCHAR(150) NOT NULL, conditions TEXT NOT NULL,
actions VARCHAR(150) NOT NULL, actions TEXT NOT NULL,
UNIQUE(user_name, rule_id) UNIQUE(user_name, rule_id)
); );
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(150), user_id TEXT,
filter_id BIGINT UNSIGNED, filter_id BIGINT UNSIGNED,
filter_json LONGBLOB filter_json LONGBLOB
); );

View File

@ -15,10 +15,10 @@
CREATE TABLE IF NOT EXISTS application_services( CREATE TABLE IF NOT EXISTS application_services(
id INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER PRIMARY KEY AUTOINCREMENT,
url VARCHAR(150), url TEXT,
token VARCHAR(150), token TEXT,
hs_token VARCHAR(150), hs_token TEXT,
sender VARCHAR(150), sender TEXT,
UNIQUE(token) UNIQUE(token)
); );
@ -26,6 +26,6 @@ CREATE TABLE IF NOT EXISTS application_services_regex(
id INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER PRIMARY KEY AUTOINCREMENT,
as_id BIGINT UNSIGNED NOT NULL, as_id BIGINT UNSIGNED NOT NULL,
namespace INTEGER, /* enum[room_id|room_alias|user_id] */ namespace INTEGER, /* enum[room_id|room_alias|user_id] */
regex VARCHAR(150), regex TEXT,
FOREIGN KEY(as_id) REFERENCES application_services(id) FOREIGN KEY(as_id) REFERENCES application_services(id)
); );

View File

@ -14,8 +14,8 @@
*/ */
CREATE TABLE IF NOT EXISTS push_rules_enable ( CREATE TABLE IF NOT EXISTS push_rules_enable (
id INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER PRIMARY KEY AUTOINCREMENT,
user_name VARCHAR(150) NOT NULL, user_name TEXT NOT NULL,
rule_id VARCHAR(150) NOT NULL, rule_id TEXT NOT NULL,
enabled TINYINT, enabled TINYINT,
UNIQUE(user_name, rule_id) UNIQUE(user_name, rule_id)
); );

View File

@ -14,13 +14,13 @@
*/ */
CREATE TABLE IF NOT EXISTS application_services_state( CREATE TABLE IF NOT EXISTS application_services_state(
as_id VARCHAR(150) PRIMARY KEY, as_id TEXT PRIMARY KEY,
state VARCHAR(5), state VARCHAR(5),
last_txn INTEGER last_txn INTEGER
); );
CREATE TABLE IF NOT EXISTS application_services_txns( CREATE TABLE IF NOT EXISTS application_services_txns(
as_id VARCHAR(150) NOT NULL, as_id TEXT NOT NULL,
txn_id INTEGER NOT NULL, txn_id INTEGER NOT NULL,
event_ids TEXT NOT NULL, event_ids TEXT NOT NULL,
UNIQUE(as_id, txn_id) UNIQUE(as_id, txn_id)

View File

@ -2,9 +2,9 @@
-- MUST BE DONE BEFORE REMOVING ID COLUMN FROM USERS TABLE BELOW -- MUST BE DONE BEFORE REMOVING ID COLUMN FROM USERS TABLE BELOW
CREATE TABLE IF NOT EXISTS new_access_tokens( CREATE TABLE IF NOT EXISTS new_access_tokens(
id BIGINT UNSIGNED PRIMARY KEY, id BIGINT UNSIGNED PRIMARY KEY,
user_id VARCHAR(150) NOT NULL, user_id TEXT NOT NULL,
device_id VARCHAR(150), device_id TEXT,
token VARCHAR(150) NOT NULL, token TEXT NOT NULL,
last_used BIGINT UNSIGNED, last_used BIGINT UNSIGNED,
UNIQUE(token) UNIQUE(token)
); );
@ -20,8 +20,8 @@ ALTER TABLE new_access_tokens RENAME TO access_tokens;
-- Remove ID column from `users` table -- Remove ID column from `users` table
CREATE TABLE IF NOT EXISTS new_users( CREATE TABLE IF NOT EXISTS new_users(
name VARCHAR(150), name TEXT,
password_hash VARCHAR(150), password_hash TEXT,
creation_ts BIGINT UNSIGNED, creation_ts BIGINT UNSIGNED,
admin BOOL DEFAULT 0 NOT NULL, admin BOOL DEFAULT 0 NOT NULL,
UNIQUE(name) UNIQUE(name)
@ -36,11 +36,11 @@ ALTER TABLE new_users RENAME TO users;
-- Remove UNIQUE constraint from `user_ips` table -- Remove UNIQUE constraint from `user_ips` table
CREATE TABLE IF NOT EXISTS new_user_ips ( CREATE TABLE IF NOT EXISTS new_user_ips (
user_id VARCHAR(150) NOT NULL, user_id TEXT NOT NULL,
access_token VARCHAR(150) NOT NULL, access_token TEXT NOT NULL,
device_id VARCHAR(150), device_id TEXT,
ip VARCHAR(150) NOT NULL, ip TEXT NOT NULL,
user_agent VARCHAR(150) NOT NULL, user_agent TEXT NOT NULL,
last_seen BIGINT UNSIGNED NOT NULL last_seen BIGINT UNSIGNED NOT NULL
); );

View File

@ -14,8 +14,8 @@
*/ */
CREATE TABLE IF NOT EXISTS event_forward_extremities( CREATE TABLE IF NOT EXISTS event_forward_extremities(
event_id VARCHAR(150) NOT NULL, event_id TEXT NOT NULL,
room_id VARCHAR(150) NOT NULL, room_id TEXT NOT NULL,
UNIQUE (event_id, room_id) UNIQUE (event_id, room_id)
); );
@ -24,8 +24,8 @@ CREATE INDEX ev_extrem_id ON event_forward_extremities(event_id);
CREATE TABLE IF NOT EXISTS event_backward_extremities( CREATE TABLE IF NOT EXISTS event_backward_extremities(
event_id VARCHAR(150) NOT NULL, event_id TEXT NOT NULL,
room_id VARCHAR(150) NOT NULL, room_id TEXT NOT NULL,
UNIQUE (event_id, room_id) UNIQUE (event_id, room_id)
); );
@ -34,9 +34,9 @@ CREATE INDEX ev_b_extrem_id ON event_backward_extremities(event_id);
CREATE TABLE IF NOT EXISTS event_edges( CREATE TABLE IF NOT EXISTS event_edges(
event_id VARCHAR(150) NOT NULL, event_id TEXT NOT NULL,
prev_event_id VARCHAR(150) NOT NULL, prev_event_id TEXT NOT NULL,
room_id VARCHAR(150) NOT NULL, room_id TEXT 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)
); );
@ -46,7 +46,7 @@ CREATE INDEX ev_edges_prev_id ON event_edges(prev_event_id);
CREATE TABLE IF NOT EXISTS room_depth( CREATE TABLE IF NOT EXISTS room_depth(
room_id VARCHAR(150) NOT NULL, room_id TEXT NOT NULL,
min_depth INTEGER NOT NULL, min_depth INTEGER NOT NULL,
UNIQUE (room_id) UNIQUE (room_id)
); );
@ -55,8 +55,8 @@ CREATE INDEX 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(150) NOT NULL, event_id TEXT NOT NULL,
destination VARCHAR(150) NOT NULL, destination TEXT NOT NULL,
delivered_ts BIGINT 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)
); );
@ -65,10 +65,10 @@ CREATE INDEX event_destinations_id ON event_destinations(event_id);
CREATE TABLE IF NOT EXISTS state_forward_extremities( CREATE TABLE IF NOT EXISTS state_forward_extremities(
event_id VARCHAR(150) NOT NULL, event_id TEXT NOT NULL,
room_id VARCHAR(150) NOT NULL, room_id TEXT NOT NULL,
type VARCHAR(150) NOT NULL, type TEXT NOT NULL,
state_key VARCHAR(150) NOT NULL, state_key TEXT NOT NULL,
UNIQUE (event_id, room_id) UNIQUE (event_id, room_id)
); );
@ -79,9 +79,9 @@ CREATE INDEX st_extrem_id ON state_forward_extremities(event_id);
CREATE TABLE IF NOT EXISTS event_auth( CREATE TABLE IF NOT EXISTS event_auth(
event_id VARCHAR(150) NOT NULL, event_id TEXT NOT NULL,
auth_id VARCHAR(150) NOT NULL, auth_id TEXT NOT NULL,
room_id VARCHAR(150) NOT NULL, room_id TEXT NOT NULL,
UNIQUE (event_id, auth_id, room_id) UNIQUE (event_id, auth_id, room_id)
); );

View File

@ -14,8 +14,8 @@
*/ */
CREATE TABLE IF NOT EXISTS event_content_hashes ( CREATE TABLE IF NOT EXISTS event_content_hashes (
event_id VARCHAR(150), event_id TEXT,
algorithm VARCHAR(150), algorithm TEXT,
hash bytea, hash bytea,
UNIQUE (event_id, algorithm) UNIQUE (event_id, algorithm)
); );
@ -24,8 +24,8 @@ CREATE INDEX event_content_hashes_id ON event_content_hashes(event_id);
CREATE TABLE IF NOT EXISTS event_reference_hashes ( CREATE TABLE IF NOT EXISTS event_reference_hashes (
event_id VARCHAR(150), event_id TEXT,
algorithm VARCHAR(150), algorithm TEXT,
hash bytea, hash bytea,
UNIQUE (event_id, algorithm) UNIQUE (event_id, algorithm)
); );
@ -34,9 +34,9 @@ CREATE INDEX event_reference_hashes_id ON event_reference_hashes(event_id);
CREATE TABLE IF NOT EXISTS event_signatures ( CREATE TABLE IF NOT EXISTS event_signatures (
event_id VARCHAR(150), event_id TEXT,
signature_name VARCHAR(150), signature_name TEXT,
key_id VARCHAR(150), key_id TEXT,
signature bytea, signature bytea,
UNIQUE (event_id, signature_name, key_id) UNIQUE (event_id, signature_name, key_id)
); );
@ -45,9 +45,9 @@ CREATE INDEX event_signatures_id ON event_signatures(event_id);
CREATE TABLE IF NOT EXISTS event_edge_hashes( CREATE TABLE IF NOT EXISTS event_edge_hashes(
event_id VARCHAR(150), event_id TEXT,
prev_event_id VARCHAR(150), prev_event_id TEXT,
algorithm VARCHAR(150), algorithm TEXT,
hash bytea, hash bytea,
UNIQUE (event_id, prev_event_id, algorithm) UNIQUE (event_id, prev_event_id, algorithm)
); );

View File

@ -16,9 +16,9 @@
CREATE TABLE IF NOT EXISTS events( CREATE TABLE IF NOT EXISTS events(
stream_ordering INTEGER PRIMARY KEY AUTOINCREMENT, stream_ordering INTEGER PRIMARY KEY AUTOINCREMENT,
topological_ordering BIGINT NOT NULL, topological_ordering BIGINT NOT NULL,
event_id VARCHAR(150) NOT NULL, event_id TEXT NOT NULL,
type VARCHAR(150) NOT NULL, type TEXT NOT NULL,
room_id VARCHAR(150) NOT NULL, room_id TEXT NOT NULL,
content TEXT NOT NULL, content TEXT NOT NULL,
unrecognized_keys TEXT, unrecognized_keys TEXT,
processed BOOL NOT NULL, processed BOOL NOT NULL,
@ -33,8 +33,8 @@ CREATE INDEX events_room_id ON events (room_id);
CREATE TABLE IF NOT EXISTS event_json( CREATE TABLE IF NOT EXISTS event_json(
event_id VARCHAR(150) NOT NULL, event_id TEXT NOT NULL,
room_id VARCHAR(150) NOT NULL, room_id TEXT NOT NULL,
internal_metadata TEXT NOT NULL, internal_metadata TEXT NOT NULL,
json TEXT NOT NULL, json TEXT NOT NULL,
UNIQUE (event_id) UNIQUE (event_id)
@ -44,11 +44,11 @@ CREATE INDEX event_json_room_id ON event_json(room_id);
CREATE TABLE IF NOT EXISTS state_events( CREATE TABLE IF NOT EXISTS state_events(
event_id VARCHAR(150) NOT NULL, event_id TEXT NOT NULL,
room_id VARCHAR(150) NOT NULL, room_id TEXT NOT NULL,
type VARCHAR(150) NOT NULL, type TEXT NOT NULL,
state_key VARCHAR(150) NOT NULL, state_key TEXT NOT NULL,
prev_state VARCHAR(150), prev_state TEXT,
UNIQUE (event_id) UNIQUE (event_id)
); );
@ -58,10 +58,10 @@ CREATE INDEX state_events_state_key ON state_events (state_key);
CREATE TABLE IF NOT EXISTS current_state_events( CREATE TABLE IF NOT EXISTS current_state_events(
event_id VARCHAR(150) NOT NULL, event_id TEXT NOT NULL,
room_id VARCHAR(150) NOT NULL, room_id TEXT NOT NULL,
type VARCHAR(150) NOT NULL, type TEXT NOT NULL,
state_key VARCHAR(150) NOT NULL, state_key TEXT NOT NULL,
UNIQUE (room_id, type, state_key) UNIQUE (room_id, type, state_key)
); );
@ -71,11 +71,11 @@ 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 INDEX current_state_events_state_key ON current_state_events (state_key);
CREATE TABLE IF NOT EXISTS room_memberships( CREATE TABLE IF NOT EXISTS room_memberships(
event_id VARCHAR(150) NOT NULL, event_id TEXT NOT NULL,
user_id VARCHAR(150) NOT NULL, user_id TEXT NOT NULL,
sender VARCHAR(150) NOT NULL, sender TEXT NOT NULL,
room_id VARCHAR(150) NOT NULL, room_id TEXT NOT NULL,
membership VARCHAR(150) NOT NULL membership TEXT NOT NULL
); );
CREATE INDEX room_memberships_event_id ON room_memberships (event_id); CREATE INDEX room_memberships_event_id ON room_memberships (event_id);
@ -83,16 +83,16 @@ CREATE INDEX room_memberships_room_id ON room_memberships (room_id);
CREATE INDEX room_memberships_user_id ON room_memberships (user_id); CREATE INDEX room_memberships_user_id ON room_memberships (user_id);
CREATE TABLE IF NOT EXISTS feedback( CREATE TABLE IF NOT EXISTS feedback(
event_id VARCHAR(150) NOT NULL, event_id TEXT NOT NULL,
feedback_type VARCHAR(150), feedback_type TEXT,
target_event_id VARCHAR(150), target_event_id TEXT,
sender VARCHAR(150), sender TEXT,
room_id VARCHAR(150) room_id TEXT
); );
CREATE TABLE IF NOT EXISTS topics( CREATE TABLE IF NOT EXISTS topics(
event_id VARCHAR(150) NOT NULL, event_id TEXT NOT NULL,
room_id VARCHAR(150) NOT NULL, room_id TEXT NOT NULL,
topic TEXT NOT NULL topic TEXT NOT NULL
); );
@ -100,8 +100,8 @@ CREATE INDEX topics_event_id ON topics(event_id);
CREATE INDEX topics_room_id ON topics(room_id); CREATE INDEX topics_room_id ON topics(room_id);
CREATE TABLE IF NOT EXISTS room_names( CREATE TABLE IF NOT EXISTS room_names(
event_id VARCHAR(150) NOT NULL, event_id TEXT NOT NULL,
room_id VARCHAR(150) NOT NULL, room_id TEXT NOT NULL,
name TEXT NOT NULL name TEXT NOT NULL
); );
@ -109,14 +109,14 @@ CREATE INDEX room_names_event_id ON room_names(event_id);
CREATE INDEX room_names_room_id ON room_names(room_id); CREATE INDEX room_names_room_id ON room_names(room_id);
CREATE TABLE IF NOT EXISTS rooms( CREATE TABLE IF NOT EXISTS rooms(
room_id VARCHAR(150) PRIMARY KEY NOT NULL, room_id TEXT PRIMARY KEY NOT NULL,
is_public BOOL, is_public BOOL,
creator VARCHAR(150) creator TEXT
); );
CREATE TABLE IF NOT EXISTS room_hosts( CREATE TABLE IF NOT EXISTS room_hosts(
room_id VARCHAR(150) NOT NULL, room_id TEXT NOT NULL,
host VARCHAR(150) NOT NULL, host TEXT NOT NULL,
UNIQUE (room_id, host) UNIQUE (room_id, host)
); );

View File

@ -13,18 +13,18 @@
* limitations under the License. * limitations under the License.
*/ */
CREATE TABLE IF NOT EXISTS server_tls_certificates( CREATE TABLE IF NOT EXISTS server_tls_certificates(
server_name VARCHAR(150), -- Server name. server_name TEXT, -- Server name.
fingerprint VARCHAR(150), -- Certificate fingerprint. fingerprint TEXT, -- Certificate fingerprint.
from_server VARCHAR(150), -- Which key server the certificate was fetched from. from_server TEXT, -- Which key server the certificate was fetched from.
ts_added_ms BIGINT, -- When the certifcate was added. ts_added_ms BIGINT, -- When the certifcate was added.
tls_certificate bytea, -- DER encoded x509 certificate. tls_certificate bytea, -- DER encoded x509 certificate.
UNIQUE (server_name, fingerprint) UNIQUE (server_name, fingerprint)
); );
CREATE TABLE IF NOT EXISTS server_signature_keys( CREATE TABLE IF NOT EXISTS server_signature_keys(
server_name VARCHAR(150), -- Server name. server_name TEXT, -- Server name.
key_id VARCHAR(150), -- Key version. key_id TEXT, -- Key version.
from_server VARCHAR(150), -- Which key server the key was fetched form. from_server TEXT, -- Which key server the key was fetched form.
ts_added_ms BIGINT, -- When the key was added. ts_added_ms BIGINT, -- When the key was added.
verify_key bytea, -- NACL verification key. verify_key bytea, -- NACL verification key.
UNIQUE (server_name, key_id) UNIQUE (server_name, key_id)

View File

@ -14,21 +14,21 @@
*/ */
CREATE TABLE IF NOT EXISTS local_media_repository ( CREATE TABLE IF NOT EXISTS local_media_repository (
media_id VARCHAR(150), -- The id used to refer to the media. media_id TEXT, -- The id used to refer to the media.
media_type VARCHAR(150), -- The MIME-type of the media. media_type TEXT, -- 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 BIGINT, -- 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. upload_name TEXT, -- The name the media was uploaded with.
user_id VARCHAR(150), -- The user who uploaded the file. user_id TEXT, -- The user who uploaded the file.
UNIQUE (media_id) UNIQUE (media_id)
); );
CREATE TABLE IF NOT EXISTS local_media_repository_thumbnails ( CREATE TABLE IF NOT EXISTS local_media_repository_thumbnails (
media_id VARCHAR(150), -- The id used to refer to the media. media_id TEXT, -- The id used to refer to the media.
thumbnail_width INTEGER, -- The width of the thumbnail in pixels. thumbnail_width INTEGER, -- The width of the thumbnail in pixels.
thumbnail_height INTEGER, -- The height of the thumbnail in pixels. thumbnail_height INTEGER, -- The height of the thumbnail in pixels.
thumbnail_type VARCHAR(150), -- The MIME-type of the thumbnail. thumbnail_type TEXT, -- The MIME-type of the thumbnail.
thumbnail_method VARCHAR(150), -- The method used to make the thumbnail. thumbnail_method TEXT, -- The method used to make the thumbnail.
thumbnail_length INTEGER, -- The length of the thumbnail in bytes. thumbnail_length INTEGER, -- The length of the thumbnail in bytes.
UNIQUE ( UNIQUE (
media_id, thumbnail_width, thumbnail_height, thumbnail_type media_id, thumbnail_width, thumbnail_height, thumbnail_type
@ -39,25 +39,25 @@ CREATE INDEX local_media_repository_thumbnails_media_id
ON local_media_repository_thumbnails (media_id); ON local_media_repository_thumbnails (media_id);
CREATE TABLE IF NOT EXISTS remote_media_cache ( CREATE TABLE IF NOT EXISTS remote_media_cache (
media_origin VARCHAR(150), -- The remote HS the media came from. media_origin TEXT, -- The remote HS the media came from.
media_id VARCHAR(150), -- The id used to refer to the media on that server. media_id TEXT, -- The id used to refer to the media on that server.
media_type VARCHAR(150), -- The MIME-type of the media. media_type TEXT, -- The MIME-type of the media.
created_ts BIGINT, -- 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. upload_name TEXT, -- 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(150), -- The name used to store the media on disk. filesystem_id TEXT, -- The name used to store the media on disk.
UNIQUE (media_origin, media_id) UNIQUE (media_origin, media_id)
); );
CREATE TABLE IF NOT EXISTS remote_media_cache_thumbnails ( CREATE TABLE IF NOT EXISTS remote_media_cache_thumbnails (
media_origin VARCHAR(150), -- The remote HS the media came from. media_origin TEXT, -- The remote HS the media came from.
media_id VARCHAR(150), -- The id used to refer to the media. media_id TEXT, -- The id used to refer to the media.
thumbnail_width INTEGER, -- The width of the thumbnail in pixels. thumbnail_width INTEGER, -- The width of the thumbnail in pixels.
thumbnail_height INTEGER, -- The height of the thumbnail in pixels. thumbnail_height INTEGER, -- The height of the thumbnail in pixels.
thumbnail_method VARCHAR(150), -- The method used to make the thumbnail thumbnail_method TEXT, -- The method used to make the thumbnail
thumbnail_type VARCHAR(150), -- The MIME-type of the thumbnail. thumbnail_type TEXT, -- The MIME-type of the thumbnail.
thumbnail_length INTEGER, -- The length of the thumbnail in bytes. thumbnail_length INTEGER, -- The length of the thumbnail in bytes.
filesystem_id VARCHAR(150), -- The name used to store the media on disk. filesystem_id TEXT, -- The name used to store the media on disk.
UNIQUE ( UNIQUE (
media_origin, media_id, thumbnail_width, thumbnail_height, media_origin, media_id, thumbnail_width, thumbnail_height,
thumbnail_type thumbnail_type

View File

@ -13,23 +13,23 @@
* limitations under the License. * limitations under the License.
*/ */
CREATE TABLE IF NOT EXISTS presence( CREATE TABLE IF NOT EXISTS presence(
user_id VARCHAR(150) NOT NULL, user_id TEXT NOT NULL,
state VARCHAR(20), state VARCHAR(20),
status_msg VARCHAR(150), status_msg TEXT,
mtime BIGINT -- 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 -- For each of /my/ users which possibly-remote users are allowed to see their
-- presence state -- presence state
CREATE TABLE IF NOT EXISTS presence_allow_inbound( CREATE TABLE IF NOT EXISTS presence_allow_inbound(
observed_user_id VARCHAR(150) NOT NULL, observed_user_id TEXT NOT NULL,
observer_user_id VARCHAR(150) NOT NULL -- a UserID, observer_user_id TEXT NOT NULL -- a UserID,
); );
-- 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?
CREATE TABLE IF NOT EXISTS presence_list( CREATE TABLE IF NOT EXISTS presence_list(
user_id VARCHAR(150) NOT NULL, user_id TEXT NOT NULL,
observed_user_id VARCHAR(150) NOT NULL, -- a UserID, observed_user_id TEXT NOT NULL, -- a UserID,
accepted BOOLEAN NOT NULL accepted BOOLEAN NOT NULL
); );

View File

@ -13,7 +13,7 @@
* limitations under the License. * limitations under the License.
*/ */
CREATE TABLE IF NOT EXISTS profiles( CREATE TABLE IF NOT EXISTS profiles(
user_id VARCHAR(150) NOT NULL, user_id TEXT NOT NULL,
displayname VARCHAR(150), displayname TEXT,
avatar_url VARCHAR(150) avatar_url TEXT
); );

View File

@ -13,8 +13,8 @@
* limitations under the License. * limitations under the License.
*/ */
CREATE TABLE IF NOT EXISTS redactions ( CREATE TABLE IF NOT EXISTS redactions (
event_id VARCHAR(150) NOT NULL, event_id TEXT NOT NULL,
redacts VARCHAR(150) NOT NULL, redacts TEXT NOT NULL,
UNIQUE (event_id) UNIQUE (event_id)
); );

View File

@ -14,11 +14,11 @@
*/ */
CREATE TABLE IF NOT EXISTS room_aliases( CREATE TABLE IF NOT EXISTS room_aliases(
room_alias VARCHAR(150) NOT NULL, room_alias TEXT NOT NULL,
room_id VARCHAR(150) NOT NULL room_id TEXT NOT NULL
); );
CREATE TABLE IF NOT EXISTS room_alias_servers( CREATE TABLE IF NOT EXISTS room_alias_servers(
room_alias VARCHAR(150) NOT NULL, room_alias TEXT NOT NULL,
server VARCHAR(150) NOT NULL server TEXT NOT NULL
); );

View File

@ -15,20 +15,20 @@
CREATE TABLE IF NOT EXISTS state_groups( CREATE TABLE IF NOT EXISTS state_groups(
id INTEGER PRIMARY KEY, id INTEGER PRIMARY KEY,
room_id VARCHAR(150) NOT NULL, room_id TEXT NOT NULL,
event_id VARCHAR(150) NOT NULL event_id TEXT NOT NULL
); );
CREATE TABLE IF NOT EXISTS state_groups_state( CREATE TABLE IF NOT EXISTS state_groups_state(
state_group INTEGER NOT NULL, state_group INTEGER NOT NULL,
room_id VARCHAR(150) NOT NULL, room_id TEXT NOT NULL,
type VARCHAR(150) NOT NULL, type TEXT NOT NULL,
state_key VARCHAR(150) NOT NULL, state_key TEXT NOT NULL,
event_id VARCHAR(150) NOT NULL event_id TEXT NOT NULL
); );
CREATE TABLE IF NOT EXISTS event_to_state_groups( CREATE TABLE IF NOT EXISTS event_to_state_groups(
event_id VARCHAR(150) NOT NULL, event_id TEXT NOT NULL,
state_group INTEGER NOT NULL, state_group INTEGER NOT NULL,
UNIQUE (event_id) UNIQUE (event_id)
); );

View File

@ -14,8 +14,8 @@
*/ */
-- Stores what transaction ids we have received and what our response was -- Stores what transaction ids we have received and what our response was
CREATE TABLE IF NOT EXISTS received_transactions( CREATE TABLE IF NOT EXISTS received_transactions(
transaction_id VARCHAR(150), transaction_id TEXT,
origin VARCHAR(150), origin TEXT,
ts BIGINT, ts BIGINT,
response_code INTEGER, response_code INTEGER,
response_json bytea, response_json bytea,
@ -30,8 +30,8 @@ CREATE INDEX transactions_have_ref ON received_transactions(origin, has_been_ref
-- 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 AUTOINCREMENT, -- This is used to apply insertion ordering id INTEGER PRIMARY KEY AUTOINCREMENT, -- This is used to apply insertion ordering
transaction_id VARCHAR(150), transaction_id TEXT,
destination VARCHAR(150), destination TEXT,
response_code INTEGER DEFAULT 0, response_code INTEGER DEFAULT 0,
response_json TEXT, response_json TEXT,
ts BIGINT ts BIGINT
@ -47,9 +47,9 @@ CREATE INDEX sent_transaction_sent ON sent_transactions(response_code);
-- For sent transactions only. -- For sent transactions only.
CREATE TABLE IF NOT EXISTS transaction_id_to_pdu( CREATE TABLE IF NOT EXISTS transaction_id_to_pdu(
transaction_id INTEGER, transaction_id INTEGER,
destination VARCHAR(150), destination TEXT,
pdu_id VARCHAR(150), pdu_id TEXT,
pdu_origin VARCHAR(150) pdu_origin TEXT
); );
CREATE INDEX transaction_id_to_pdu_tx ON transaction_id_to_pdu(transaction_id, destination); CREATE INDEX transaction_id_to_pdu_tx ON transaction_id_to_pdu(transaction_id, destination);
@ -57,7 +57,7 @@ CREATE INDEX 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(150) PRIMARY KEY, destination TEXT PRIMARY KEY,
retry_last_ts BIGINT, retry_last_ts BIGINT,
retry_interval INTEGER retry_interval INTEGER
); );

View File

@ -14,8 +14,8 @@
*/ */
CREATE TABLE IF NOT EXISTS users( CREATE TABLE IF NOT EXISTS users(
id INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(150), name TEXT,
password_hash VARCHAR(150), password_hash TEXT,
creation_ts BIGINT, creation_ts BIGINT,
admin SMALLINT DEFAULT 0 NOT NULL, admin SMALLINT DEFAULT 0 NOT NULL,
UNIQUE(name) UNIQUE(name)
@ -23,18 +23,18 @@ CREATE TABLE IF NOT EXISTS users(
CREATE TABLE IF NOT EXISTS access_tokens( CREATE TABLE IF NOT EXISTS access_tokens(
id INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER PRIMARY KEY AUTOINCREMENT,
user_id VARCHAR(150) NOT NULL, user_id TEXT NOT NULL,
device_id VARCHAR(150), device_id TEXT,
token VARCHAR(150) NOT NULL, token TEXT NOT NULL,
last_used BIGINT, last_used BIGINT,
UNIQUE(token) UNIQUE(token)
); );
CREATE TABLE IF NOT EXISTS user_ips ( CREATE TABLE IF NOT EXISTS user_ips (
user VARCHAR(150) NOT NULL, user TEXT NOT NULL,
access_token VARCHAR(150) NOT NULL, access_token TEXT NOT NULL,
device_id VARCHAR(150), device_id TEXT,
ip VARCHAR(150) NOT NULL, ip TEXT NOT NULL,
user_agent TEXT NOT NULL, user_agent TEXT NOT NULL,
last_seen BIGINT NOT NULL, last_seen BIGINT NOT NULL,
UNIQUE (user, access_token, ip, user_agent) UNIQUE (user, access_token, ip, user_agent)

View File

@ -15,10 +15,10 @@
CREATE TABLE IF NOT EXISTS application_services( CREATE TABLE IF NOT EXISTS application_services(
id BIGINT PRIMARY KEY, id BIGINT PRIMARY KEY,
url VARCHAR(150), url TEXT,
token VARCHAR(150), token TEXT,
hs_token VARCHAR(150), hs_token TEXT,
sender VARCHAR(150), sender TEXT,
UNIQUE(token) UNIQUE(token)
); );
@ -26,18 +26,18 @@ CREATE TABLE IF NOT EXISTS application_services_regex(
id BIGINT PRIMARY KEY, id BIGINT PRIMARY KEY,
as_id BIGINT 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(150), regex TEXT,
FOREIGN KEY(as_id) REFERENCES application_services(id) FOREIGN KEY(as_id) REFERENCES application_services(id)
); );
CREATE TABLE IF NOT EXISTS application_services_state( CREATE TABLE IF NOT EXISTS application_services_state(
as_id VARCHAR(150) PRIMARY KEY, as_id TEXT PRIMARY KEY,
state VARCHAR(5), state VARCHAR(5),
last_txn INTEGER last_txn INTEGER
); );
CREATE TABLE IF NOT EXISTS application_services_txns( CREATE TABLE IF NOT EXISTS application_services_txns(
as_id VARCHAR(150) NOT NULL, as_id TEXT NOT NULL,
txn_id INTEGER NOT NULL, txn_id INTEGER NOT NULL,
event_ids TEXT NOT NULL, event_ids TEXT NOT NULL,
UNIQUE(as_id, txn_id) UNIQUE(as_id, txn_id)

View File

@ -14,8 +14,8 @@
*/ */
CREATE TABLE IF NOT EXISTS event_forward_extremities( CREATE TABLE IF NOT EXISTS event_forward_extremities(
event_id VARCHAR(150) NOT NULL, event_id TEXT NOT NULL,
room_id VARCHAR(150) NOT NULL, room_id TEXT NOT NULL,
UNIQUE (event_id, room_id) UNIQUE (event_id, room_id)
); );
@ -24,8 +24,8 @@ CREATE INDEX ev_extrem_id ON event_forward_extremities(event_id);
CREATE TABLE IF NOT EXISTS event_backward_extremities( CREATE TABLE IF NOT EXISTS event_backward_extremities(
event_id VARCHAR(150) NOT NULL, event_id TEXT NOT NULL,
room_id VARCHAR(150) NOT NULL, room_id TEXT NOT NULL,
UNIQUE (event_id, room_id) UNIQUE (event_id, room_id)
); );
@ -34,9 +34,9 @@ CREATE INDEX ev_b_extrem_id ON event_backward_extremities(event_id);
CREATE TABLE IF NOT EXISTS event_edges( CREATE TABLE IF NOT EXISTS event_edges(
event_id VARCHAR(150) NOT NULL, event_id TEXT NOT NULL,
prev_event_id VARCHAR(150) NOT NULL, prev_event_id TEXT NOT NULL,
room_id VARCHAR(150) NOT NULL, room_id TEXT 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)
); );
@ -46,7 +46,7 @@ CREATE INDEX ev_edges_prev_id ON event_edges(prev_event_id);
CREATE TABLE IF NOT EXISTS room_depth( CREATE TABLE IF NOT EXISTS room_depth(
room_id VARCHAR(150) NOT NULL, room_id TEXT NOT NULL,
min_depth INTEGER NOT NULL, min_depth INTEGER NOT NULL,
UNIQUE (room_id) UNIQUE (room_id)
); );
@ -55,8 +55,8 @@ CREATE INDEX 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(150) NOT NULL, event_id TEXT NOT NULL,
destination VARCHAR(150) NOT NULL, destination TEXT NOT NULL,
delivered_ts BIGINT 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)
); );
@ -65,10 +65,10 @@ CREATE INDEX event_destinations_id ON event_destinations(event_id);
CREATE TABLE IF NOT EXISTS state_forward_extremities( CREATE TABLE IF NOT EXISTS state_forward_extremities(
event_id VARCHAR(150) NOT NULL, event_id TEXT NOT NULL,
room_id VARCHAR(150) NOT NULL, room_id TEXT NOT NULL,
type VARCHAR(150) NOT NULL, type TEXT NOT NULL,
state_key VARCHAR(150) NOT NULL, state_key TEXT NOT NULL,
UNIQUE (event_id, room_id) UNIQUE (event_id, room_id)
); );
@ -79,9 +79,9 @@ CREATE INDEX st_extrem_id ON state_forward_extremities(event_id);
CREATE TABLE IF NOT EXISTS event_auth( CREATE TABLE IF NOT EXISTS event_auth(
event_id VARCHAR(150) NOT NULL, event_id TEXT NOT NULL,
auth_id VARCHAR(150) NOT NULL, auth_id TEXT NOT NULL,
room_id VARCHAR(150) NOT NULL, room_id TEXT NOT NULL,
UNIQUE (event_id, auth_id, room_id) UNIQUE (event_id, auth_id, room_id)
); );

View File

@ -14,8 +14,8 @@
*/ */
CREATE TABLE IF NOT EXISTS event_content_hashes ( CREATE TABLE IF NOT EXISTS event_content_hashes (
event_id VARCHAR(150), event_id TEXT,
algorithm VARCHAR(150), algorithm TEXT,
hash bytea, hash bytea,
UNIQUE (event_id, algorithm) UNIQUE (event_id, algorithm)
); );
@ -24,8 +24,8 @@ CREATE INDEX event_content_hashes_id ON event_content_hashes(event_id);
CREATE TABLE IF NOT EXISTS event_reference_hashes ( CREATE TABLE IF NOT EXISTS event_reference_hashes (
event_id VARCHAR(150), event_id TEXT,
algorithm VARCHAR(150), algorithm TEXT,
hash bytea, hash bytea,
UNIQUE (event_id, algorithm) UNIQUE (event_id, algorithm)
); );
@ -34,9 +34,9 @@ CREATE INDEX event_reference_hashes_id ON event_reference_hashes(event_id);
CREATE TABLE IF NOT EXISTS event_signatures ( CREATE TABLE IF NOT EXISTS event_signatures (
event_id VARCHAR(150), event_id TEXT,
signature_name VARCHAR(150), signature_name TEXT,
key_id VARCHAR(150), key_id TEXT,
signature bytea, signature bytea,
UNIQUE (event_id, signature_name, key_id) UNIQUE (event_id, signature_name, key_id)
); );
@ -45,9 +45,9 @@ CREATE INDEX event_signatures_id ON event_signatures(event_id);
CREATE TABLE IF NOT EXISTS event_edge_hashes( CREATE TABLE IF NOT EXISTS event_edge_hashes(
event_id VARCHAR(150), event_id TEXT,
prev_event_id VARCHAR(150), prev_event_id TEXT,
algorithm VARCHAR(150), algorithm TEXT,
hash bytea, hash bytea,
UNIQUE (event_id, prev_event_id, algorithm) UNIQUE (event_id, prev_event_id, algorithm)
); );

View File

@ -16,9 +16,9 @@
CREATE TABLE IF NOT EXISTS events( CREATE TABLE IF NOT EXISTS events(
stream_ordering INTEGER PRIMARY KEY, stream_ordering INTEGER PRIMARY KEY,
topological_ordering BIGINT NOT NULL, topological_ordering BIGINT NOT NULL,
event_id VARCHAR(150) NOT NULL, event_id TEXT NOT NULL,
type VARCHAR(150) NOT NULL, type TEXT NOT NULL,
room_id VARCHAR(150) NOT NULL, room_id TEXT NOT NULL,
content TEXT NOT NULL, content TEXT NOT NULL,
unrecognized_keys TEXT, unrecognized_keys TEXT,
processed BOOL NOT NULL, processed BOOL NOT NULL,
@ -37,8 +37,8 @@ CREATE INDEX events_order_room ON events (
CREATE TABLE IF NOT EXISTS event_json( CREATE TABLE IF NOT EXISTS event_json(
event_id VARCHAR(150) NOT NULL, event_id TEXT NOT NULL,
room_id VARCHAR(150) NOT NULL, room_id TEXT NOT NULL,
internal_metadata TEXT NOT NULL, internal_metadata TEXT NOT NULL,
json TEXT NOT NULL, json TEXT NOT NULL,
UNIQUE (event_id) UNIQUE (event_id)
@ -48,11 +48,11 @@ CREATE INDEX event_json_room_id ON event_json(room_id);
CREATE TABLE IF NOT EXISTS state_events( CREATE TABLE IF NOT EXISTS state_events(
event_id VARCHAR(150) NOT NULL, event_id TEXT NOT NULL,
room_id VARCHAR(150) NOT NULL, room_id TEXT NOT NULL,
type VARCHAR(150) NOT NULL, type TEXT NOT NULL,
state_key VARCHAR(150) NOT NULL, state_key TEXT NOT NULL,
prev_state VARCHAR(150), prev_state TEXT,
UNIQUE (event_id) UNIQUE (event_id)
); );
@ -62,10 +62,10 @@ CREATE INDEX state_events_state_key ON state_events (state_key);
CREATE TABLE IF NOT EXISTS current_state_events( CREATE TABLE IF NOT EXISTS current_state_events(
event_id VARCHAR(150) NOT NULL, event_id TEXT NOT NULL,
room_id VARCHAR(150) NOT NULL, room_id TEXT NOT NULL,
type VARCHAR(150) NOT NULL, type TEXT NOT NULL,
state_key VARCHAR(150) NOT NULL, state_key TEXT NOT NULL,
UNIQUE (event_id), UNIQUE (event_id),
UNIQUE (room_id, type, state_key) UNIQUE (room_id, type, state_key)
); );
@ -75,11 +75,11 @@ 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 INDEX current_state_events_state_key ON current_state_events (state_key);
CREATE TABLE IF NOT EXISTS room_memberships( CREATE TABLE IF NOT EXISTS room_memberships(
event_id VARCHAR(150) NOT NULL, event_id TEXT NOT NULL,
user_id VARCHAR(150) NOT NULL, user_id TEXT NOT NULL,
sender VARCHAR(150) NOT NULL, sender TEXT NOT NULL,
room_id VARCHAR(150) NOT NULL, room_id TEXT NOT NULL,
membership VARCHAR(150) NOT NULL, membership TEXT NOT NULL,
UNIQUE (event_id) UNIQUE (event_id)
); );
@ -87,17 +87,17 @@ CREATE INDEX room_memberships_room_id ON room_memberships (room_id);
CREATE INDEX room_memberships_user_id ON room_memberships (user_id); CREATE INDEX room_memberships_user_id ON room_memberships (user_id);
CREATE TABLE IF NOT EXISTS feedback( CREATE TABLE IF NOT EXISTS feedback(
event_id VARCHAR(150) NOT NULL, event_id TEXT NOT NULL,
feedback_type VARCHAR(150), feedback_type TEXT,
target_event_id VARCHAR(150), target_event_id TEXT,
sender VARCHAR(150), sender TEXT,
room_id VARCHAR(150), room_id TEXT,
UNIQUE (event_id) UNIQUE (event_id)
); );
CREATE TABLE IF NOT EXISTS topics( CREATE TABLE IF NOT EXISTS topics(
event_id VARCHAR(150) NOT NULL, event_id TEXT NOT NULL,
room_id VARCHAR(150) NOT NULL, room_id TEXT NOT NULL,
topic TEXT NOT NULL, topic TEXT NOT NULL,
UNIQUE (event_id) UNIQUE (event_id)
); );
@ -105,8 +105,8 @@ CREATE TABLE IF NOT EXISTS topics(
CREATE INDEX topics_room_id ON topics(room_id); CREATE INDEX topics_room_id ON topics(room_id);
CREATE TABLE IF NOT EXISTS room_names( CREATE TABLE IF NOT EXISTS room_names(
event_id VARCHAR(150) NOT NULL, event_id TEXT NOT NULL,
room_id VARCHAR(150) NOT NULL, room_id TEXT NOT NULL,
name TEXT NOT NULL, name TEXT NOT NULL,
UNIQUE (event_id) UNIQUE (event_id)
); );
@ -114,14 +114,14 @@ CREATE TABLE IF NOT EXISTS room_names(
CREATE INDEX room_names_room_id ON room_names(room_id); CREATE INDEX room_names_room_id ON room_names(room_id);
CREATE TABLE IF NOT EXISTS rooms( CREATE TABLE IF NOT EXISTS rooms(
room_id VARCHAR(150) PRIMARY KEY NOT NULL, room_id TEXT PRIMARY KEY NOT NULL,
is_public BOOL, is_public BOOL,
creator VARCHAR(150) creator TEXT
); );
CREATE TABLE IF NOT EXISTS room_hosts( CREATE TABLE IF NOT EXISTS room_hosts(
room_id VARCHAR(150) NOT NULL, room_id TEXT NOT NULL,
host VARCHAR(150) NOT NULL, host TEXT NOT NULL,
UNIQUE (room_id, host) UNIQUE (room_id, host)
); );

View File

@ -13,18 +13,18 @@
* limitations under the License. * limitations under the License.
*/ */
CREATE TABLE IF NOT EXISTS server_tls_certificates( CREATE TABLE IF NOT EXISTS server_tls_certificates(
server_name VARCHAR(150), -- Server name. server_name TEXT, -- Server name.
fingerprint VARCHAR(150), -- Certificate fingerprint. fingerprint TEXT, -- Certificate fingerprint.
from_server VARCHAR(150), -- Which key server the certificate was fetched from. from_server TEXT, -- Which key server the certificate was fetched from.
ts_added_ms BIGINT, -- When the certifcate was added. ts_added_ms BIGINT, -- When the certifcate was added.
tls_certificate bytea, -- DER encoded x509 certificate. tls_certificate bytea, -- DER encoded x509 certificate.
UNIQUE (server_name, fingerprint) UNIQUE (server_name, fingerprint)
); );
CREATE TABLE IF NOT EXISTS server_signature_keys( CREATE TABLE IF NOT EXISTS server_signature_keys(
server_name VARCHAR(150), -- Server name. server_name TEXT, -- Server name.
key_id VARCHAR(150), -- Key version. key_id TEXT, -- Key version.
from_server VARCHAR(150), -- Which key server the key was fetched form. from_server TEXT, -- Which key server the key was fetched form.
ts_added_ms BIGINT, -- When the key was added. ts_added_ms BIGINT, -- When the key was added.
verify_key bytea, -- NACL verification key. verify_key bytea, -- NACL verification key.
UNIQUE (server_name, key_id) UNIQUE (server_name, key_id)

View File

@ -14,21 +14,21 @@
*/ */
CREATE TABLE IF NOT EXISTS local_media_repository ( CREATE TABLE IF NOT EXISTS local_media_repository (
media_id VARCHAR(150), -- The id used to refer to the media. media_id TEXT, -- The id used to refer to the media.
media_type VARCHAR(150), -- The MIME-type of the media. media_type TEXT, -- 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 BIGINT, -- 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. upload_name TEXT, -- The name the media was uploaded with.
user_id VARCHAR(150), -- The user who uploaded the file. user_id TEXT, -- The user who uploaded the file.
UNIQUE (media_id) UNIQUE (media_id)
); );
CREATE TABLE IF NOT EXISTS local_media_repository_thumbnails ( CREATE TABLE IF NOT EXISTS local_media_repository_thumbnails (
media_id VARCHAR(150), -- The id used to refer to the media. media_id TEXT, -- The id used to refer to the media.
thumbnail_width INTEGER, -- The width of the thumbnail in pixels. thumbnail_width INTEGER, -- The width of the thumbnail in pixels.
thumbnail_height INTEGER, -- The height of the thumbnail in pixels. thumbnail_height INTEGER, -- The height of the thumbnail in pixels.
thumbnail_type VARCHAR(150), -- The MIME-type of the thumbnail. thumbnail_type TEXT, -- The MIME-type of the thumbnail.
thumbnail_method VARCHAR(150), -- The method used to make the thumbnail. thumbnail_method TEXT, -- The method used to make the thumbnail.
thumbnail_length INTEGER, -- The length of the thumbnail in bytes. thumbnail_length INTEGER, -- The length of the thumbnail in bytes.
UNIQUE ( UNIQUE (
media_id, thumbnail_width, thumbnail_height, thumbnail_type media_id, thumbnail_width, thumbnail_height, thumbnail_type
@ -39,25 +39,25 @@ CREATE INDEX local_media_repository_thumbnails_media_id
ON local_media_repository_thumbnails (media_id); ON local_media_repository_thumbnails (media_id);
CREATE TABLE IF NOT EXISTS remote_media_cache ( CREATE TABLE IF NOT EXISTS remote_media_cache (
media_origin VARCHAR(150), -- The remote HS the media came from. media_origin TEXT, -- The remote HS the media came from.
media_id VARCHAR(150), -- The id used to refer to the media on that server. media_id TEXT, -- The id used to refer to the media on that server.
media_type VARCHAR(150), -- The MIME-type of the media. media_type TEXT, -- The MIME-type of the media.
created_ts BIGINT, -- 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. upload_name TEXT, -- 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(150), -- The name used to store the media on disk. filesystem_id TEXT, -- The name used to store the media on disk.
UNIQUE (media_origin, media_id) UNIQUE (media_origin, media_id)
); );
CREATE TABLE IF NOT EXISTS remote_media_cache_thumbnails ( CREATE TABLE IF NOT EXISTS remote_media_cache_thumbnails (
media_origin VARCHAR(150), -- The remote HS the media came from. media_origin TEXT, -- The remote HS the media came from.
media_id VARCHAR(150), -- The id used to refer to the media. media_id TEXT, -- The id used to refer to the media.
thumbnail_width INTEGER, -- The width of the thumbnail in pixels. thumbnail_width INTEGER, -- The width of the thumbnail in pixels.
thumbnail_height INTEGER, -- The height of the thumbnail in pixels. thumbnail_height INTEGER, -- The height of the thumbnail in pixels.
thumbnail_method VARCHAR(150), -- The method used to make the thumbnail thumbnail_method TEXT, -- The method used to make the thumbnail
thumbnail_type VARCHAR(150), -- The MIME-type of the thumbnail. thumbnail_type TEXT, -- The MIME-type of the thumbnail.
thumbnail_length INTEGER, -- The length of the thumbnail in bytes. thumbnail_length INTEGER, -- The length of the thumbnail in bytes.
filesystem_id VARCHAR(150), -- The name used to store the media on disk. filesystem_id TEXT, -- The name used to store the media on disk.
UNIQUE ( UNIQUE (
media_origin, media_id, thumbnail_width, thumbnail_height, media_origin, media_id, thumbnail_width, thumbnail_height,
thumbnail_type thumbnail_type

View File

@ -13,9 +13,9 @@
* limitations under the License. * limitations under the License.
*/ */
CREATE TABLE IF NOT EXISTS presence( CREATE TABLE IF NOT EXISTS presence(
user_id VARCHAR(150) NOT NULL, user_id TEXT NOT NULL,
state VARCHAR(20), state VARCHAR(20),
status_msg VARCHAR(150), status_msg TEXT,
mtime BIGINT, -- miliseconds since last state change mtime BIGINT, -- miliseconds since last state change
UNIQUE (user_id) UNIQUE (user_id)
); );
@ -23,16 +23,16 @@ CREATE TABLE IF NOT EXISTS presence(
-- 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
CREATE TABLE IF NOT EXISTS presence_allow_inbound( CREATE TABLE IF NOT EXISTS presence_allow_inbound(
observed_user_id VARCHAR(150) NOT NULL, observed_user_id TEXT NOT NULL,
observer_user_id VARCHAR(150) NOT NULL, -- a UserID, observer_user_id TEXT NOT NULL, -- a UserID,
UNIQUE (observed_user_id, observer_user_id) UNIQUE (observed_user_id, observer_user_id)
); );
-- 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?
CREATE TABLE IF NOT EXISTS presence_list( CREATE TABLE IF NOT EXISTS presence_list(
user_id VARCHAR(150) NOT NULL, user_id TEXT NOT NULL,
observed_user_id VARCHAR(150) NOT NULL, -- a UserID, observed_user_id TEXT NOT NULL, -- a UserID,
accepted BOOLEAN NOT NULL, accepted BOOLEAN NOT NULL,
UNIQUE (user_id, observed_user_id) UNIQUE (user_id, observed_user_id)
); );

View File

@ -13,8 +13,8 @@
* limitations under the License. * limitations under the License.
*/ */
CREATE TABLE IF NOT EXISTS profiles( CREATE TABLE IF NOT EXISTS profiles(
user_id VARCHAR(150) NOT NULL, user_id TEXT NOT NULL,
displayname VARCHAR(150), displayname TEXT,
avatar_url VARCHAR(150), avatar_url TEXT,
UNIQUE(user_id) UNIQUE(user_id)
); );

View File

@ -14,16 +14,16 @@
*/ */
CREATE TABLE IF NOT EXISTS rejections( CREATE TABLE IF NOT EXISTS rejections(
event_id VARCHAR(150) NOT NULL, event_id TEXT NOT NULL,
reason VARCHAR(150) NOT NULL, reason TEXT NOT NULL,
last_check VARCHAR(150) NOT NULL, last_check TEXT NOT NULL,
UNIQUE (event_id) UNIQUE (event_id)
); );
-- 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 BIGINT PRIMARY KEY, id BIGINT PRIMARY KEY,
user_name VARCHAR(150) NOT NULL, user_name TEXT NOT NULL,
profile_tag VARCHAR(32) NOT NULL, profile_tag VARCHAR(32) NOT NULL,
kind VARCHAR(8) NOT NULL, kind VARCHAR(8) NOT NULL,
app_id VARCHAR(64) NOT NULL, app_id VARCHAR(64) NOT NULL,
@ -41,19 +41,19 @@ CREATE TABLE IF NOT EXISTS pushers (
CREATE TABLE IF NOT EXISTS push_rules ( CREATE TABLE IF NOT EXISTS push_rules (
id BIGINT PRIMARY KEY, id BIGINT PRIMARY KEY,
user_name VARCHAR(150) NOT NULL, user_name TEXT NOT NULL,
rule_id VARCHAR(150) NOT NULL, rule_id TEXT NOT NULL,
priority_class SMALLINT NOT NULL, priority_class SMALLINT NOT NULL,
priority INTEGER NOT NULL DEFAULT 0, priority INTEGER NOT NULL DEFAULT 0,
conditions VARCHAR(150) NOT NULL, conditions TEXT NOT NULL,
actions VARCHAR(150) NOT NULL, actions TEXT NOT NULL,
UNIQUE(user_name, rule_id) UNIQUE(user_name, rule_id)
); );
CREATE INDEX push_rules_user_name on push_rules (user_name); CREATE INDEX 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(150), user_id TEXT,
filter_id BIGINT, filter_id BIGINT,
filter_json bytea filter_json bytea
); );
@ -64,8 +64,8 @@ CREATE INDEX user_filters_by_user_id_filter_id ON user_filters(
CREATE TABLE IF NOT EXISTS push_rules_enable ( CREATE TABLE IF NOT EXISTS push_rules_enable (
id BIGINT PRIMARY KEY, id BIGINT PRIMARY KEY,
user_name VARCHAR(150) NOT NULL, user_name TEXT NOT NULL,
rule_id VARCHAR(150) NOT NULL, rule_id TEXT NOT NULL,
enabled SMALLINT, enabled SMALLINT,
UNIQUE(user_name, rule_id) UNIQUE(user_name, rule_id)
); );

View File

@ -13,8 +13,8 @@
* limitations under the License. * limitations under the License.
*/ */
CREATE TABLE IF NOT EXISTS redactions ( CREATE TABLE IF NOT EXISTS redactions (
event_id VARCHAR(150) NOT NULL, event_id TEXT NOT NULL,
redacts VARCHAR(150) NOT NULL, redacts TEXT NOT NULL,
UNIQUE (event_id) UNIQUE (event_id)
); );

View File

@ -14,16 +14,16 @@
*/ */
CREATE TABLE IF NOT EXISTS room_aliases( CREATE TABLE IF NOT EXISTS room_aliases(
room_alias VARCHAR(150) NOT NULL, room_alias TEXT NOT NULL,
room_id VARCHAR(150) NOT NULL, room_id TEXT NOT NULL,
UNIQUE (room_alias) UNIQUE (room_alias)
); );
CREATE INDEX room_aliases_id ON room_aliases(room_id); CREATE INDEX room_aliases_id ON room_aliases(room_id);
CREATE TABLE IF NOT EXISTS room_alias_servers( CREATE TABLE IF NOT EXISTS room_alias_servers(
room_alias VARCHAR(150) NOT NULL, room_alias TEXT NOT NULL,
server VARCHAR(150) NOT NULL server TEXT NOT NULL
); );
CREATE INDEX room_alias_servers_alias ON room_alias_servers(room_alias); CREATE INDEX room_alias_servers_alias ON room_alias_servers(room_alias);

View File

@ -15,20 +15,20 @@
CREATE TABLE IF NOT EXISTS state_groups( CREATE TABLE IF NOT EXISTS state_groups(
id BIGINT PRIMARY KEY, id BIGINT PRIMARY KEY,
room_id VARCHAR(150) NOT NULL, room_id TEXT NOT NULL,
event_id VARCHAR(150) NOT NULL event_id TEXT NOT NULL
); );
CREATE TABLE IF NOT EXISTS state_groups_state( CREATE TABLE IF NOT EXISTS state_groups_state(
state_group BIGINT NOT NULL, state_group BIGINT NOT NULL,
room_id VARCHAR(150) NOT NULL, room_id TEXT NOT NULL,
type VARCHAR(150) NOT NULL, type TEXT NOT NULL,
state_key VARCHAR(150) NOT NULL, state_key TEXT NOT NULL,
event_id VARCHAR(150) NOT NULL event_id TEXT NOT NULL
); );
CREATE TABLE IF NOT EXISTS event_to_state_groups( CREATE TABLE IF NOT EXISTS event_to_state_groups(
event_id VARCHAR(150) NOT NULL, event_id TEXT NOT NULL,
state_group BIGINT NOT NULL, state_group BIGINT NOT NULL,
UNIQUE (event_id) UNIQUE (event_id)
); );

View File

@ -14,8 +14,8 @@
*/ */
-- Stores what transaction ids we have received and what our response was -- Stores what transaction ids we have received and what our response was
CREATE TABLE IF NOT EXISTS received_transactions( CREATE TABLE IF NOT EXISTS received_transactions(
transaction_id VARCHAR(150), transaction_id TEXT,
origin VARCHAR(150), origin TEXT,
ts BIGINT, ts BIGINT,
response_code INTEGER, response_code INTEGER,
response_json bytea, response_json bytea,
@ -30,8 +30,8 @@ CREATE INDEX transactions_have_ref ON received_transactions(origin, has_been_ref
-- 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 BIGINT PRIMARY KEY, -- This is used to apply insertion ordering id BIGINT PRIMARY KEY, -- This is used to apply insertion ordering
transaction_id VARCHAR(150), transaction_id TEXT,
destination VARCHAR(150), destination TEXT,
response_code INTEGER DEFAULT 0, response_code INTEGER DEFAULT 0,
response_json TEXT, response_json TEXT,
ts BIGINT ts BIGINT
@ -47,9 +47,9 @@ CREATE INDEX sent_transaction_sent ON sent_transactions(response_code);
-- For sent transactions only. -- For sent transactions only.
CREATE TABLE IF NOT EXISTS transaction_id_to_pdu( CREATE TABLE IF NOT EXISTS transaction_id_to_pdu(
transaction_id INTEGER, transaction_id INTEGER,
destination VARCHAR(150), destination TEXT,
pdu_id VARCHAR(150), pdu_id TEXT,
pdu_origin VARCHAR(150), pdu_origin TEXT,
UNIQUE (transaction_id, destination) UNIQUE (transaction_id, destination)
); );
@ -57,7 +57,7 @@ CREATE INDEX 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(150) PRIMARY KEY, destination TEXT PRIMARY KEY,
retry_last_ts BIGINT, retry_last_ts BIGINT,
retry_interval INTEGER retry_interval INTEGER
); );

View File

@ -13,8 +13,8 @@
* limitations under the License. * limitations under the License.
*/ */
CREATE TABLE IF NOT EXISTS users( CREATE TABLE IF NOT EXISTS users(
name VARCHAR(150), name TEXT,
password_hash VARCHAR(150), password_hash TEXT,
creation_ts BIGINT, creation_ts BIGINT,
admin SMALLINT DEFAULT 0 NOT NULL, admin SMALLINT DEFAULT 0 NOT NULL,
UNIQUE(name) UNIQUE(name)
@ -22,18 +22,18 @@ CREATE TABLE IF NOT EXISTS users(
CREATE TABLE IF NOT EXISTS access_tokens( CREATE TABLE IF NOT EXISTS access_tokens(
id BIGINT PRIMARY KEY, id BIGINT PRIMARY KEY,
user_id VARCHAR(150) NOT NULL, user_id TEXT NOT NULL,
device_id VARCHAR(150), device_id TEXT,
token VARCHAR(150) NOT NULL, token TEXT NOT NULL,
last_used BIGINT, last_used BIGINT,
UNIQUE(token) UNIQUE(token)
); );
CREATE TABLE IF NOT EXISTS user_ips ( CREATE TABLE IF NOT EXISTS user_ips (
user_id VARCHAR(150) NOT NULL, user_id TEXT NOT NULL,
access_token VARCHAR(150) NOT NULL, access_token TEXT NOT NULL,
device_id VARCHAR(150), device_id TEXT,
ip VARCHAR(150) NOT NULL, ip TEXT NOT NULL,
user_agent TEXT NOT NULL, user_agent TEXT NOT NULL,
last_seen BIGINT NOT NULL last_seen BIGINT NOT NULL
); );

View File

@ -22,6 +22,6 @@ CREATE TABLE IF NOT EXISTS schema_version(
CREATE TABLE IF NOT EXISTS applied_schema_deltas( CREATE TABLE IF NOT EXISTS applied_schema_deltas(
version INTEGER NOT NULL, version INTEGER NOT NULL,
file VARCHAR(150) NOT NULL, file TEXT NOT NULL,
UNIQUE(version, file) UNIQUE(version, file)
); );