Update schema to work with mariadb
This commit is contained in:
parent
3f7a31d366
commit
89036579ed
|
@ -14,54 +14,50 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS rejections(
|
CREATE TABLE IF NOT EXISTS rejections(
|
||||||
event_id TEXT NOT NULL,
|
event_id VARCHAR(255) NOT NULL,
|
||||||
reason TEXT NOT NULL,
|
reason VARCHAR(255) NOT NULL,
|
||||||
last_check TEXT NOT NULL,
|
last_check VARCHAR(255) NOT NULL,
|
||||||
CONSTRAINT ev_id UNIQUE (event_id) ON CONFLICT REPLACE
|
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,
|
||||||
user_name TEXT 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,
|
||||||
app_id varchar(64) NOT NULL,
|
app_id VARCHAR(64) NOT NULL,
|
||||||
app_display_name varchar(64) NOT NULL,
|
app_display_name VARCHAR(64) NOT NULL,
|
||||||
device_display_name varchar(128) NOT NULL,
|
device_display_name VARCHAR(128) NOT NULL,
|
||||||
pushkey blob NOT NULL,
|
pushkey VARBINARY(512) NOT NULL,
|
||||||
ts BIGINT NOT NULL,
|
ts BIGINT NOT NULL,
|
||||||
lang varchar(8),
|
lang VARCHAR(8),
|
||||||
data blob,
|
data BLOB,
|
||||||
last_token TEXT,
|
last_token TEXT,
|
||||||
last_success BIGINT,
|
last_success BIGINT,
|
||||||
failing_since BIGINT,
|
failing_since BIGINT,
|
||||||
FOREIGN KEY(user_name) REFERENCES users(name),
|
|
||||||
UNIQUE (app_id, pushkey)
|
UNIQUE (app_id, pushkey)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS push_rules (
|
CREATE TABLE IF NOT EXISTS push_rules (
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
id INTEGER PRIMARY KEY,
|
||||||
user_name TEXT NOT NULL,
|
user_name VARCHAR(255) NOT NULL,
|
||||||
rule_id TEXT NOT NULL,
|
rule_id VARCHAR(255) 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 TEXT NOT NULL,
|
conditions VARCHAR(255) NOT NULL,
|
||||||
actions TEXT NOT NULL,
|
actions VARCHAR(255) 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 TEXT,
|
user_id VARCHAR(255),
|
||||||
filter_id INTEGER,
|
filter_id INTEGER,
|
||||||
filter_json TEXT,
|
filter_json BLOB
|
||||||
FOREIGN KEY(user_id) REFERENCES users(id)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
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
|
||||||
);
|
);
|
||||||
|
|
||||||
PRAGMA user_version = 12;
|
|
||||||
|
|
|
@ -14,21 +14,18 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS application_services(
|
CREATE TABLE IF NOT EXISTS application_services(
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
id INTEGER PRIMARY KEY,
|
||||||
url TEXT,
|
url VARCHAR(255),
|
||||||
token TEXT,
|
token VARCHAR(255),
|
||||||
hs_token TEXT,
|
hs_token VARCHAR(255),
|
||||||
sender TEXT,
|
sender VARCHAR(255),
|
||||||
UNIQUE(token) ON CONFLICT ROLLBACK
|
UNIQUE(token)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS application_services_regex(
|
CREATE TABLE IF NOT EXISTS application_services_regex(
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
id INTEGER PRIMARY KEY,
|
||||||
as_id INTEGER NOT NULL,
|
as_id INTEGER NOT NULL,
|
||||||
namespace INTEGER, /* enum[room_id|room_alias|user_id] */
|
namespace INTEGER, /* enum[room_id|room_alias|user_id] */
|
||||||
regex TEXT,
|
regex VARCHAR(255),
|
||||||
FOREIGN KEY(as_id) REFERENCES application_services(id)
|
FOREIGN KEY(as_id) REFERENCES application_services(id)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
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,
|
||||||
user_name TEXT NOT NULL,
|
user_name VARCHAR(255) NOT NULL,
|
||||||
rule_id TEXT NOT NULL,
|
rule_id VARCHAR(255) NOT NULL,
|
||||||
enabled TINYINT,
|
enabled TINYINT,
|
||||||
UNIQUE(user_name, rule_id)
|
UNIQUE(user_name, rule_id)
|
||||||
);
|
);
|
||||||
|
|
|
@ -14,9 +14,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS event_forward_extremities(
|
CREATE TABLE IF NOT EXISTS event_forward_extremities(
|
||||||
event_id TEXT NOT NULL,
|
event_id VARCHAR(255) NOT NULL,
|
||||||
room_id TEXT NOT NULL,
|
room_id VARCHAR(255) NOT NULL,
|
||||||
CONSTRAINT uniqueness UNIQUE (event_id, room_id) ON CONFLICT REPLACE
|
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_room ON event_forward_extremities(room_id);
|
||||||
|
@ -24,9 +24,9 @@ CREATE INDEX IF NOT EXISTS 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 TEXT NOT NULL,
|
event_id VARCHAR(255) NOT NULL,
|
||||||
room_id TEXT NOT NULL,
|
room_id VARCHAR(255) NOT NULL,
|
||||||
CONSTRAINT uniqueness UNIQUE (event_id, room_id) ON CONFLICT REPLACE
|
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_room ON event_backward_extremities(room_id);
|
||||||
|
@ -34,11 +34,11 @@ CREATE INDEX IF NOT EXISTS 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 TEXT NOT NULL,
|
event_id VARCHAR(255) NOT NULL,
|
||||||
prev_event_id TEXT NOT NULL,
|
prev_event_id VARCHAR(255) NOT NULL,
|
||||||
room_id TEXT NOT NULL,
|
room_id VARCHAR(255) NOT NULL,
|
||||||
is_state INTEGER NOT NULL,
|
is_state BOOL NOT NULL,
|
||||||
CONSTRAINT uniqueness UNIQUE (event_id, prev_event_id, room_id, is_state)
|
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_id ON event_edges(event_id);
|
||||||
|
@ -46,30 +46,30 @@ CREATE INDEX IF NOT EXISTS 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 TEXT NOT NULL,
|
room_id VARCHAR(255) NOT NULL,
|
||||||
min_depth INTEGER NOT NULL,
|
min_depth INTEGER NOT NULL,
|
||||||
CONSTRAINT uniqueness UNIQUE (room_id)
|
UNIQUE (room_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
|
|
||||||
create TABLE IF NOT EXISTS event_destinations(
|
create TABLE IF NOT EXISTS event_destinations(
|
||||||
event_id TEXT NOT NULL,
|
event_id VARCHAR(255) NOT NULL,
|
||||||
destination TEXT NOT NULL,
|
destination VARCHAR(255) NOT NULL,
|
||||||
delivered_ts INTEGER DEFAULT 0, -- or 0 if not delivered
|
delivered_ts INTEGER DEFAULT 0, -- or 0 if not delivered
|
||||||
CONSTRAINT uniqueness UNIQUE (event_id, destination) ON CONFLICT REPLACE
|
UNIQUE (event_id, destination)
|
||||||
);
|
);
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS state_forward_extremities(
|
CREATE TABLE IF NOT EXISTS state_forward_extremities(
|
||||||
event_id TEXT NOT NULL,
|
event_id VARCHAR(255) NOT NULL,
|
||||||
room_id TEXT NOT NULL,
|
room_id VARCHAR(255) NOT NULL,
|
||||||
type TEXT NOT NULL,
|
type VARCHAR(255) NOT NULL,
|
||||||
state_key TEXT NOT NULL,
|
state_key VARCHAR(255) NOT NULL,
|
||||||
CONSTRAINT uniqueness UNIQUE (event_id, room_id) ON CONFLICT REPLACE
|
UNIQUE (event_id, room_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS st_extrem_keys ON state_forward_extremities(
|
CREATE INDEX IF NOT EXISTS st_extrem_keys ON state_forward_extremities(
|
||||||
|
@ -79,11 +79,11 @@ CREATE INDEX IF NOT EXISTS 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 TEXT NOT NULL,
|
event_id VARCHAR(255) NOT NULL,
|
||||||
auth_id TEXT NOT NULL,
|
auth_id VARCHAR(255) NOT NULL,
|
||||||
room_id TEXT NOT NULL,
|
room_id VARCHAR(255) NOT NULL,
|
||||||
CONSTRAINT uniqueness UNIQUE (event_id, auth_id, room_id)
|
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_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);
|
||||||
|
|
|
@ -14,52 +14,42 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS event_content_hashes (
|
CREATE TABLE IF NOT EXISTS event_content_hashes (
|
||||||
event_id TEXT,
|
event_id VARCHAR(255),
|
||||||
algorithm TEXT,
|
algorithm VARCHAR(255),
|
||||||
hash BLOB,
|
hash BLOB,
|
||||||
CONSTRAINT uniqueness UNIQUE (event_id, algorithm)
|
UNIQUE (event_id, algorithm)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS event_content_hashes_id ON event_content_hashes(
|
CREATE INDEX IF NOT EXISTS event_content_hashes_id ON event_content_hashes(event_id);
|
||||||
event_id
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS event_reference_hashes (
|
CREATE TABLE IF NOT EXISTS event_reference_hashes (
|
||||||
event_id TEXT,
|
event_id VARCHAR(255),
|
||||||
algorithm TEXT,
|
algorithm VARCHAR(255),
|
||||||
hash BLOB,
|
hash BLOB,
|
||||||
CONSTRAINT uniqueness UNIQUE (event_id, algorithm)
|
UNIQUE (event_id, algorithm)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS event_reference_hashes_id ON event_reference_hashes (
|
CREATE INDEX IF NOT EXISTS event_reference_hashes_id ON event_reference_hashes(event_id);
|
||||||
event_id
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS event_signatures (
|
CREATE TABLE IF NOT EXISTS event_signatures (
|
||||||
event_id TEXT,
|
event_id VARCHAR(255),
|
||||||
signature_name TEXT,
|
signature_name VARCHAR(255),
|
||||||
key_id TEXT,
|
key_id VARCHAR(255),
|
||||||
signature BLOB,
|
signature BLOB,
|
||||||
CONSTRAINT uniqueness UNIQUE (event_id, signature_name, key_id)
|
UNIQUE (event_id, signature_name, key_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS event_signatures_id ON event_signatures (
|
CREATE INDEX IF NOT EXISTS event_signatures_id ON event_signatures(event_id);
|
||||||
event_id
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS event_edge_hashes(
|
CREATE TABLE IF NOT EXISTS event_edge_hashes(
|
||||||
event_id TEXT,
|
event_id VARCHAR(255),
|
||||||
prev_event_id TEXT,
|
prev_event_id VARCHAR(255),
|
||||||
algorithm TEXT,
|
algorithm VARCHAR(255),
|
||||||
hash BLOB,
|
hash BLOB,
|
||||||
CONSTRAINT uniqueness UNIQUE (
|
UNIQUE (event_id, prev_event_id, algorithm)
|
||||||
event_id, prev_event_id, algorithm
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS event_edge_hashes_id ON event_edge_hashes(
|
CREATE INDEX IF NOT EXISTS event_edge_hashes_id ON event_edge_hashes(event_id);
|
||||||
event_id
|
|
||||||
);
|
|
||||||
|
|
|
@ -14,17 +14,17 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS events(
|
CREATE TABLE IF NOT EXISTS events(
|
||||||
stream_ordering INTEGER PRIMARY KEY AUTOINCREMENT,
|
stream_ordering INTEGER PRIMARY KEY,
|
||||||
topological_ordering INTEGER NOT NULL,
|
topological_ordering INTEGER NOT NULL,
|
||||||
event_id TEXT NOT NULL,
|
event_id VARCHAR(255) NOT NULL,
|
||||||
type TEXT NOT NULL,
|
type VARCHAR(255) NOT NULL,
|
||||||
room_id TEXT NOT NULL,
|
room_id VARCHAR(255) NOT NULL,
|
||||||
content TEXT NOT NULL,
|
content BLOB NOT NULL,
|
||||||
unrecognized_keys TEXT,
|
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 INTEGER DEFAULT 0 NOT NULL,
|
||||||
CONSTRAINT ev_uniq UNIQUE (event_id)
|
UNIQUE (event_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS events_event_id ON events (event_id);
|
CREATE INDEX IF NOT EXISTS events_event_id ON events (event_id);
|
||||||
|
@ -34,92 +34,92 @@ CREATE INDEX IF NOT EXISTS events_room_id ON events (room_id);
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS event_json(
|
CREATE TABLE IF NOT EXISTS event_json(
|
||||||
event_id TEXT NOT NULL,
|
event_id VARCHAR(255) NOT NULL,
|
||||||
room_id TEXT NOT NULL,
|
room_id VARCHAR(255) NOT NULL,
|
||||||
internal_metadata NOT NULL,
|
internal_metadata BLOB NOT NULL,
|
||||||
json BLOB NOT NULL,
|
json BLOB NOT NULL,
|
||||||
CONSTRAINT ev_j_uniq UNIQUE (event_id)
|
UNIQUE (event_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS event_json_id ON event_json(event_id);
|
|
||||||
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 IF NOT EXISTS state_events(
|
CREATE TABLE state_events(
|
||||||
event_id TEXT NOT NULL,
|
event_id VARCHAR(255) NOT NULL,
|
||||||
room_id TEXT NOT NULL,
|
room_id VARCHAR(255) NOT NULL,
|
||||||
type TEXT NOT NULL,
|
type VARCHAR(255) NOT NULL,
|
||||||
state_key TEXT NOT NULL,
|
state_key VARCHAR(255) NOT NULL,
|
||||||
prev_state TEXT
|
prev_state VARCHAR(255),
|
||||||
|
UNIQUE (event_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE UNIQUE INDEX IF NOT EXISTS state_events_event_id ON state_events (event_id);
|
|
||||||
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);
|
||||||
CREATE INDEX IF NOT EXISTS state_events_state_key ON state_events (state_key);
|
CREATE INDEX IF NOT EXISTS 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 TEXT NOT NULL,
|
event_id VARCHAR(255) NOT NULL,
|
||||||
room_id TEXT NOT NULL,
|
room_id VARCHAR(255) NOT NULL,
|
||||||
type TEXT NOT NULL,
|
type VARCHAR(255) NOT NULL,
|
||||||
state_key TEXT NOT NULL,
|
state_key VARCHAR(255) NOT NULL,
|
||||||
CONSTRAINT curr_uniq UNIQUE (room_id, type, state_key) ON CONFLICT REPLACE
|
UNIQUE (event_id),
|
||||||
|
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_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);
|
||||||
CREATE INDEX IF NOT EXISTS current_state_events_state_key ON current_state_events (state_key);
|
CREATE INDEX IF NOT EXISTS 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 TEXT NOT NULL,
|
event_id VARCHAR(255) NOT NULL,
|
||||||
user_id TEXT NOT NULL,
|
user_id VARCHAR(255) NOT NULL,
|
||||||
sender TEXT NOT NULL,
|
sender VARCHAR(255) NOT NULL,
|
||||||
room_id TEXT NOT NULL,
|
room_id VARCHAR(255) NOT NULL,
|
||||||
membership TEXT NOT NULL
|
membership VARCHAR(255) NOT NULL,
|
||||||
|
UNIQUE (event_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
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_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);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS feedback(
|
CREATE TABLE IF NOT EXISTS feedback(
|
||||||
event_id TEXT NOT NULL,
|
event_id VARCHAR(255) NOT NULL,
|
||||||
feedback_type TEXT,
|
feedback_type VARCHAR(255),
|
||||||
target_event_id TEXT,
|
target_event_id VARCHAR(255),
|
||||||
sender TEXT,
|
sender VARCHAR(255),
|
||||||
room_id TEXT
|
room_id VARCHAR(255),
|
||||||
|
UNIQUE (event_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS topics(
|
CREATE TABLE IF NOT EXISTS topics(
|
||||||
event_id TEXT NOT NULL,
|
event_id VARCHAR(255) NOT NULL,
|
||||||
room_id TEXT NOT NULL,
|
room_id VARCHAR(255) NOT NULL,
|
||||||
topic TEXT NOT NULL
|
topic VARCHAR(255) NOT NULL,
|
||||||
|
UNIQUE (event_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
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 IF NOT EXISTS topics_room_id ON topics(room_id);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS room_names(
|
CREATE TABLE IF NOT EXISTS room_names(
|
||||||
event_id TEXT NOT NULL,
|
event_id VARCHAR(255) NOT NULL,
|
||||||
room_id TEXT NOT NULL,
|
room_id VARCHAR(255) NOT NULL,
|
||||||
name TEXT NOT NULL
|
name VARCHAR(255) NOT NULL,
|
||||||
|
UNIQUE (event_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
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 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 TEXT PRIMARY KEY NOT NULL,
|
room_id VARCHAR(255) PRIMARY KEY NOT NULL,
|
||||||
is_public INTEGER,
|
is_public INTEGER,
|
||||||
creator TEXT
|
creator VARCHAR(255)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS room_hosts(
|
CREATE TABLE IF NOT EXISTS room_hosts(
|
||||||
room_id TEXT NOT NULL,
|
room_id VARCHAR(255) NOT NULL,
|
||||||
host TEXT NOT NULL,
|
host VARCHAR(255) NOT NULL,
|
||||||
CONSTRAINT room_hosts_uniq UNIQUE (room_id, host) ON CONFLICT IGNORE
|
UNIQUE (room_id, host)
|
||||||
);
|
);
|
||||||
|
|
||||||
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);
|
||||||
|
|
|
@ -13,19 +13,19 @@
|
||||||
* 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 TEXT, -- Server name.
|
server_name VARCHAR(255), -- Server name.
|
||||||
fingerprint TEXT, -- Certificate fingerprint.
|
fingerprint VARCHAR(255), -- Certificate fingerprint.
|
||||||
from_server TEXT, -- 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 INTEGER, -- When the certifcate was added.
|
||||||
tls_certificate BLOB, -- DER encoded x509 certificate.
|
tls_certificate BLOB, -- DER encoded x509 certificate.
|
||||||
CONSTRAINT uniqueness 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 TEXT, -- Server name.
|
server_name VARCHAR(255), -- Server name.
|
||||||
key_id TEXT, -- Key version.
|
key_id VARCHAR(255), -- Key version.
|
||||||
from_server TEXT, -- 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 INTEGER, -- When the key was added.
|
||||||
verify_key BLOB, -- NACL verification key.
|
verify_key BLOB, -- NACL verification key.
|
||||||
CONSTRAINT uniqueness UNIQUE (server_name, key_id)
|
UNIQUE (server_name, key_id)
|
||||||
);
|
);
|
||||||
|
|
|
@ -14,23 +14,23 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS local_media_repository (
|
CREATE TABLE IF NOT EXISTS local_media_repository (
|
||||||
media_id TEXT, -- The id used to refer to the media.
|
media_id VARCHAR(255), -- The id used to refer to the media.
|
||||||
media_type TEXT, -- 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 INTEGER, -- When the content was uploaded in ms.
|
||||||
upload_name TEXT, -- The name the media was uploaded with.
|
upload_name VARCHAR(255), -- The name the media was uploaded with.
|
||||||
user_id TEXT, -- The user who uploaded the file.
|
user_id VARCHAR(255), -- The user who uploaded the file.
|
||||||
CONSTRAINT uniqueness 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 TEXT, -- The id used to refer to the media.
|
media_id VARCHAR(255), -- 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 TEXT, -- The MIME-type of the thumbnail.
|
thumbnail_type VARCHAR(255), -- The MIME-type of the thumbnail.
|
||||||
thumbnail_method TEXT, -- The method used to make the thumbnail.
|
thumbnail_method VARCHAR(255), -- 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.
|
||||||
CONSTRAINT uniqueness UNIQUE (
|
UNIQUE (
|
||||||
media_id, thumbnail_width, thumbnail_height, thumbnail_type
|
media_id, thumbnail_width, thumbnail_height, thumbnail_type
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -39,29 +39,29 @@ 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);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS remote_media_cache (
|
CREATE TABLE IF NOT EXISTS remote_media_cache (
|
||||||
media_origin TEXT, -- The remote HS the media came from.
|
media_origin VARCHAR(255), -- The remote HS the media came from.
|
||||||
media_id TEXT, -- 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 TEXT, -- 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 INTEGER, -- When the content was uploaded in ms.
|
||||||
upload_name TEXT, -- 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 TEXT, -- The name used to store the media on disk.
|
filesystem_id VARCHAR(255), -- The name used to store the media on disk.
|
||||||
CONSTRAINT uniqueness 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 TEXT, -- The remote HS the media came from.
|
media_origin VARCHAR(255), -- The remote HS the media came from.
|
||||||
media_id TEXT, -- The id used to refer to the media.
|
media_id VARCHAR(255), -- 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 TEXT, -- The method used to make the thumbnail
|
thumbnail_method VARCHAR(255), -- The method used to make the thumbnail
|
||||||
thumbnail_type TEXT, -- The MIME-type of the thumbnail.
|
thumbnail_type VARCHAR(255), -- 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 TEXT, -- The name used to store the media on disk.
|
filesystem_id VARCHAR(255), -- The name used to store the media on disk.
|
||||||
CONSTRAINT uniqueness UNIQUE (
|
UNIQUE (
|
||||||
media_origin, media_id, thumbnail_width, thumbnail_height,
|
media_origin, media_id, thumbnail_width, thumbnail_height,
|
||||||
thumbnail_type, thumbnail_type
|
thumbnail_type
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS remote_media_cache_thumbnails_media_id
|
CREATE INDEX IF NOT EXISTS remote_media_cache_thumbnails_media_id
|
||||||
|
|
|
@ -13,26 +13,26 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
CREATE TABLE IF NOT EXISTS presence(
|
CREATE TABLE IF NOT EXISTS presence(
|
||||||
user_id INTEGER NOT NULL,
|
user_id VARCHAR(255) NOT NULL,
|
||||||
state INTEGER,
|
state INTEGER,
|
||||||
status_msg TEXT,
|
status_msg VARCHAR(255),
|
||||||
mtime INTEGER, -- miliseconds since last state change
|
mtime INTEGER, -- miliseconds since last state change
|
||||||
FOREIGN KEY(user_id) REFERENCES users(id)
|
UNIQUE(user_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
-- 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 INTEGER NOT NULL,
|
observed_user_id VARCHAR(255) NOT NULL,
|
||||||
observer_user_id TEXT, -- a UserID,
|
observer_user_id VARCHAR(255), -- a UserID,
|
||||||
FOREIGN KEY(observed_user_id) REFERENCES users(id)
|
UNIQUE(observed_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 INTEGER NOT NULL,
|
user_id VARCHAR(255) NOT NULL,
|
||||||
observed_user_id TEXT, -- a UserID,
|
observed_user_id VARCHAR(255), -- a UserID,
|
||||||
accepted BOOLEAN,
|
accepted BOOLEAN,
|
||||||
FOREIGN KEY(user_id) REFERENCES users(id)
|
UNIQUE(user_id)
|
||||||
);
|
);
|
||||||
|
|
|
@ -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 INTEGER NOT NULL,
|
user_id VARCHAR(255) NOT NULL,
|
||||||
displayname TEXT,
|
displayname VARCHAR(255),
|
||||||
avatar_url TEXT,
|
avatar_url VARCHAR(255),
|
||||||
FOREIGN KEY(user_id) REFERENCES users(id)
|
UNIQUE(user_id)
|
||||||
);
|
);
|
||||||
|
|
|
@ -13,9 +13,9 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
CREATE TABLE IF NOT EXISTS redactions (
|
CREATE TABLE IF NOT EXISTS redactions (
|
||||||
event_id TEXT NOT NULL,
|
event_id VARCHAR(255) NOT NULL,
|
||||||
redacts TEXT NOT NULL,
|
redacts VARCHAR(255) NOT NULL,
|
||||||
CONSTRAINT ev_uniq UNIQUE (event_id)
|
UNIQUE (event_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS redactions_event_id ON redactions (event_id);
|
CREATE INDEX IF NOT EXISTS redactions_event_id ON redactions (event_id);
|
||||||
|
|
|
@ -14,14 +14,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS room_aliases(
|
CREATE TABLE IF NOT EXISTS room_aliases(
|
||||||
room_alias TEXT NOT NULL,
|
room_alias VARCHAR(255) NOT NULL,
|
||||||
room_id TEXT NOT NULL
|
room_id VARCHAR(255) NOT NULL,
|
||||||
|
UNIQUE (room_alias)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS room_alias_servers(
|
CREATE TABLE IF NOT EXISTS room_alias_servers(
|
||||||
room_alias TEXT NOT NULL,
|
room_alias VARCHAR(255) NOT NULL,
|
||||||
server TEXT NOT NULL
|
server VARCHAR(255) NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -15,33 +15,26 @@
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS state_groups(
|
CREATE TABLE IF NOT EXISTS state_groups(
|
||||||
id INTEGER PRIMARY KEY,
|
id INTEGER PRIMARY KEY,
|
||||||
room_id TEXT NOT NULL,
|
room_id VARCHAR(255) NOT NULL,
|
||||||
event_id TEXT NOT NULL
|
event_id VARCHAR(255) 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 TEXT NOT NULL,
|
room_id VARCHAR(255) NOT NULL,
|
||||||
type TEXT NOT NULL,
|
type VARCHAR(255) NOT NULL,
|
||||||
state_key TEXT NOT NULL,
|
state_key VARCHAR(255) NOT NULL,
|
||||||
event_id TEXT NOT NULL
|
event_id VARCHAR(255) NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS event_to_state_groups(
|
CREATE TABLE IF NOT EXISTS event_to_state_groups(
|
||||||
event_id TEXT NOT NULL,
|
event_id VARCHAR(255) NOT NULL,
|
||||||
state_group INTEGER NOT NULL,
|
state_group INTEGER NOT NULL,
|
||||||
CONSTRAINT event_to_state_groups_uniq UNIQUE (event_id)
|
UNIQUE (event_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS state_groups_id ON state_groups(id);
|
CREATE INDEX IF NOT EXISTS state_groups_id ON state_groups(id);
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS state_groups_state_id ON state_groups_state(
|
CREATE INDEX IF NOT EXISTS state_groups_state_id ON state_groups_state(state_group);
|
||||||
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 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
|
|
||||||
);
|
|
|
@ -14,34 +14,31 @@
|
||||||
*/
|
*/
|
||||||
-- 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 TEXT,
|
transaction_id VARCHAR(255),
|
||||||
origin TEXT,
|
origin VARCHAR(255),
|
||||||
ts INTEGER,
|
ts INTEGER,
|
||||||
response_code INTEGER,
|
response_code INTEGER,
|
||||||
response_json TEXT,
|
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
|
||||||
CONSTRAINT uniquesss UNIQUE (transaction_id, origin) ON CONFLICT REPLACE
|
UNIQUE (transaction_id, origin)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE UNIQUE INDEX IF NOT EXISTS transactions_txid ON received_transactions(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 IF NOT EXISTS 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
|
-- 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 AUTOINCREMENT, -- This is used to apply insertion ordering
|
id INTEGER PRIMARY KEY, -- This is used to apply insertion ordering
|
||||||
transaction_id TEXT,
|
transaction_id VARCHAR(255),
|
||||||
destination TEXT,
|
destination VARCHAR(255),
|
||||||
response_code INTEGER DEFAULT 0,
|
response_code INTEGER DEFAULT 0,
|
||||||
response_json TEXT,
|
response_json BLOB,
|
||||||
ts INTEGER
|
ts INTEGER
|
||||||
);
|
);
|
||||||
|
|
||||||
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(
|
CREATE INDEX IF NOT EXISTS sent_transaction_dest_referenced ON sent_transactions(destination);
|
||||||
destination
|
|
||||||
);
|
|
||||||
CREATE INDEX IF NOT EXISTS sent_transaction_txn_id ON sent_transactions(transaction_id);
|
CREATE INDEX IF NOT EXISTS 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
|
-- So that we can do an efficient look up of all transactions that have yet to be successfully
|
||||||
-- sent.
|
-- sent.
|
||||||
|
@ -51,18 +48,17 @@ CREATE INDEX IF NOT EXISTS sent_transaction_sent ON sent_transactions(response_c
|
||||||
-- 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 TEXT,
|
destination VARCHAR(255),
|
||||||
pdu_id TEXT,
|
pdu_id VARCHAR(255),
|
||||||
pdu_origin TEXT
|
pdu_origin VARCHAR(255),
|
||||||
|
UNIQUE (transaction_id, destination)
|
||||||
);
|
);
|
||||||
|
|
||||||
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 IF NOT EXISTS transaction_id_to_pdu_dest ON transaction_id_to_pdu(destination);
|
||||||
CREATE INDEX IF NOT EXISTS transaction_id_to_pdu_index ON transaction_id_to_pdu(transaction_id, destination);
|
|
||||||
|
|
||||||
-- To track destination health
|
-- To track destination health
|
||||||
CREATE TABLE IF NOT EXISTS destinations(
|
CREATE TABLE IF NOT EXISTS destinations(
|
||||||
destination TEXT PRIMARY KEY,
|
destination VARCHAR(255) PRIMARY KEY,
|
||||||
retry_last_ts INTEGER,
|
retry_last_ts INTEGER,
|
||||||
retry_interval INTEGER
|
retry_interval INTEGER
|
||||||
);
|
);
|
||||||
|
|
|
@ -13,33 +13,32 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
CREATE TABLE IF NOT EXISTS users(
|
CREATE TABLE IF NOT EXISTS users(
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
id INTEGER PRIMARY KEY,
|
||||||
name TEXT,
|
name VARCHAR(255),
|
||||||
password_hash TEXT,
|
password_hash VARBINARY(255),
|
||||||
creation_ts INTEGER,
|
creation_ts INTEGER,
|
||||||
admin BOOL DEFAULT 0 NOT NULL,
|
admin BOOL DEFAULT 0 NOT NULL,
|
||||||
UNIQUE(name) ON CONFLICT ROLLBACK
|
UNIQUE(name)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS access_tokens(
|
CREATE TABLE IF NOT EXISTS access_tokens(
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
id INTEGER PRIMARY KEY,
|
||||||
user_id INTEGER NOT NULL,
|
user_id INTEGER NOT NULL,
|
||||||
device_id TEXT,
|
device_id VARCHAR(255),
|
||||||
token TEXT NOT NULL,
|
token VARCHAR(255) NOT NULL,
|
||||||
last_used INTEGER,
|
last_used INTEGER,
|
||||||
FOREIGN KEY(user_id) REFERENCES users(id),
|
FOREIGN KEY(user_id) REFERENCES users(id),
|
||||||
UNIQUE(token) ON CONFLICT ROLLBACK
|
UNIQUE(token)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS user_ips (
|
CREATE TABLE IF NOT EXISTS user_ips (
|
||||||
user TEXT NOT NULL,
|
user VARCHAR(255) NOT NULL,
|
||||||
access_token TEXT NOT NULL,
|
access_token VARCHAR(255) NOT NULL,
|
||||||
device_id TEXT,
|
device_id VARCHAR(255),
|
||||||
ip TEXT NOT NULL,
|
ip VARCHAR(255) NOT NULL,
|
||||||
user_agent TEXT NOT NULL,
|
user_agent VARCHAR(255) NOT NULL,
|
||||||
last_seen INTEGER NOT NULL,
|
last_seen INTEGER NOT NULL,
|
||||||
CONSTRAINT user_ip UNIQUE (user, access_token, ip, user_agent) ON CONFLICT REPLACE
|
UNIQUE (user, access_token, ip, user_agent)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS user_ips_user ON user_ips(user);
|
CREATE INDEX IF NOT EXISTS user_ips_user ON user_ips(user);
|
||||||
|
|
||||||
|
|
|
@ -14,17 +14,16 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS schema_version(
|
CREATE TABLE IF NOT EXISTS schema_version(
|
||||||
Lock char(1) NOT NULL DEFAULT 'X', -- Makes sure this table only has one row.
|
`Lock` CHAR(1) NOT NULL DEFAULT 'X' UNIQUE, -- Makes sure this table only has one row.
|
||||||
version INTEGER NOT NULL,
|
`version` INTEGER NOT NULL,
|
||||||
upgraded BOOL NOT NULL, -- Whether we reached this version from an upgrade or an initial schema.
|
`upgraded` BOOL NOT NULL, -- Whether we reached this version from an upgrade or an initial schema.
|
||||||
CONSTRAINT schema_version_lock_x CHECK (Lock='X')
|
CHECK (`Lock`='X')
|
||||||
CONSTRAINT schema_version_lock_uniq UNIQUE (Lock)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
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 TEXT NOT NULL,
|
`file` VARCHAR(255) NOT NULL,
|
||||||
CONSTRAINT schema_deltas_ver_file UNIQUE (version, file) ON CONFLICT IGNORE
|
UNIQUE(version, file)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS schema_deltas_ver ON applied_schema_deltas(version);
|
CREATE INDEX IF NOT EXISTS schema_deltas_ver ON applied_schema_deltas(version);
|
||||||
|
|
Loading…
Reference in New Issue