mirror of
https://github.com/element-hq/synapse.git
synced 2024-11-23 01:55:53 +03:00
Use unsigned bigint
This commit is contained in:
parent
0f12772e32
commit
7e863c51e6
19 changed files with 50 additions and 50 deletions
|
@ -30,12 +30,12 @@ CREATE TABLE IF NOT EXISTS pushers (
|
|||
app_display_name VARCHAR(64) NOT NULL,
|
||||
device_display_name VARCHAR(128) NOT NULL,
|
||||
pushkey VARBINARY(512) NOT NULL,
|
||||
ts BIGINT NOT NULL,
|
||||
ts BIGINT UNSIGNED NOT NULL,
|
||||
lang VARCHAR(8),
|
||||
data BLOB,
|
||||
last_token TEXT,
|
||||
last_success BIGINT,
|
||||
failing_since BIGINT,
|
||||
last_success BIGINT UNSIGNED,
|
||||
failing_since BIGINT UNSIGNED,
|
||||
UNIQUE (app_id, pushkey)
|
||||
);
|
||||
|
||||
|
@ -54,7 +54,7 @@ CREATE INDEX IF NOT EXISTS push_rules_user_name on push_rules (user_name);
|
|||
|
||||
CREATE TABLE IF NOT EXISTS user_filters(
|
||||
user_id VARCHAR(150),
|
||||
filter_id BIGINT,
|
||||
filter_id BIGINT UNSIGNED,
|
||||
filter_json BLOB
|
||||
);
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ CREATE TABLE IF NOT EXISTS application_services(
|
|||
|
||||
CREATE TABLE IF NOT EXISTS application_services_regex(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
as_id BIGINT NOT NULL,
|
||||
as_id BIGINT UNSIGNED NOT NULL,
|
||||
namespace INTEGER, /* enum[room_id|room_alias|user_id] */
|
||||
regex VARCHAR(150),
|
||||
FOREIGN KEY(as_id) REFERENCES application_services(id)
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
-- Convert `access_tokens`.user from rowids to user strings.
|
||||
-- MUST BE DONE BEFORE REMOVING ID COLUMN FROM USERS TABLE BELOW
|
||||
CREATE TABLE IF NOT EXISTS new_access_tokens(
|
||||
id BIGINT PRIMARY KEY,
|
||||
id BIGINT UNSIGNED PRIMARY KEY,
|
||||
user_id VARCHAR(150) NOT NULL,
|
||||
device_id VARCHAR(150),
|
||||
token VARCHAR(150) NOT NULL,
|
||||
last_used BIGINT,
|
||||
last_used BIGINT UNSIGNED,
|
||||
UNIQUE(token)
|
||||
);
|
||||
|
||||
|
@ -22,7 +22,7 @@ ALTER TABLE new_access_tokens RENAME TO access_tokens;
|
|||
CREATE TABLE IF NOT EXISTS new_users(
|
||||
name VARCHAR(150),
|
||||
password_hash VARCHAR(150),
|
||||
creation_ts BIGINT,
|
||||
creation_ts BIGINT UNSIGNED,
|
||||
admin BOOL DEFAULT 0 NOT NULL,
|
||||
UNIQUE(name)
|
||||
);
|
||||
|
@ -41,7 +41,7 @@ CREATE TABLE IF NOT EXISTS new_user_ips (
|
|||
device_id VARCHAR(150),
|
||||
ip VARCHAR(150) NOT NULL,
|
||||
user_agent VARCHAR(150) NOT NULL,
|
||||
last_seen BIGINT NOT NULL
|
||||
last_seen BIGINT UNSIGNED NOT NULL
|
||||
);
|
||||
|
||||
INSERT INTO new_user_ips
|
||||
|
|
|
@ -57,7 +57,7 @@ CREATE INDEX IF NOT EXISTS room_depth_room ON room_depth(room_id);
|
|||
create TABLE IF NOT EXISTS event_destinations(
|
||||
event_id VARCHAR(150) NOT NULL,
|
||||
destination VARCHAR(150) NOT NULL,
|
||||
delivered_ts BIGINT DEFAULT 0, -- or 0 if not delivered
|
||||
delivered_ts BIGINT UNSIGNED DEFAULT 0, -- or 0 if not delivered
|
||||
UNIQUE (event_id, destination)
|
||||
);
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
CREATE TABLE IF NOT EXISTS events(
|
||||
stream_ordering INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
topological_ordering BIGINT NOT NULL,
|
||||
topological_ordering BIGINT UNSIGNED NOT NULL,
|
||||
event_id VARCHAR(150) NOT NULL,
|
||||
type VARCHAR(150) NOT NULL,
|
||||
room_id VARCHAR(150) NOT NULL,
|
||||
|
@ -23,7 +23,7 @@ CREATE TABLE IF NOT EXISTS events(
|
|||
unrecognized_keys BLOB,
|
||||
processed BOOL NOT NULL,
|
||||
outlier BOOL NOT NULL,
|
||||
depth BIGINT DEFAULT 0 NOT NULL,
|
||||
depth BIGINT UNSIGNED DEFAULT 0 NOT NULL,
|
||||
UNIQUE (event_id)
|
||||
);
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ CREATE TABLE IF NOT EXISTS server_tls_certificates(
|
|||
server_name VARCHAR(150), -- Server name.
|
||||
fingerprint VARCHAR(150), -- Certificate fingerprint.
|
||||
from_server VARCHAR(150), -- Which key server the certificate was fetched from.
|
||||
ts_added_ms BIGINT, -- When the certifcate was added.
|
||||
ts_added_ms BIGINT UNSIGNED, -- When the certifcate was added.
|
||||
tls_certificate BLOB, -- DER encoded x509 certificate.
|
||||
UNIQUE (server_name, fingerprint)
|
||||
);
|
||||
|
@ -25,7 +25,7 @@ CREATE TABLE IF NOT EXISTS server_signature_keys(
|
|||
server_name VARCHAR(150), -- Server name.
|
||||
key_id VARCHAR(150), -- Key version.
|
||||
from_server VARCHAR(150), -- Which key server the key was fetched form.
|
||||
ts_added_ms BIGINT, -- When the key was added.
|
||||
ts_added_ms BIGINT UNSIGNED, -- When the key was added.
|
||||
verify_key BLOB, -- NACL verification key.
|
||||
UNIQUE (server_name, key_id)
|
||||
);
|
||||
|
|
|
@ -17,7 +17,7 @@ CREATE TABLE IF NOT EXISTS local_media_repository (
|
|||
media_id VARCHAR(150), -- The id used to refer to the media.
|
||||
media_type VARCHAR(150), -- The MIME-type of the media.
|
||||
media_length INTEGER, -- Length of the media in bytes.
|
||||
created_ts BIGINT, -- When the content was uploaded in ms.
|
||||
created_ts BIGINT UNSIGNED, -- When the content was uploaded in ms.
|
||||
upload_name VARCHAR(150), -- The name the media was uploaded with.
|
||||
user_id VARCHAR(150), -- The user who uploaded the file.
|
||||
UNIQUE (media_id)
|
||||
|
@ -42,7 +42,7 @@ CREATE TABLE IF NOT EXISTS remote_media_cache (
|
|||
media_origin VARCHAR(150), -- The remote HS the media came from.
|
||||
media_id VARCHAR(150), -- The id used to refer to the media on that server.
|
||||
media_type VARCHAR(150), -- The MIME-type of the media.
|
||||
created_ts BIGINT, -- When the content was uploaded in ms.
|
||||
created_ts BIGINT UNSIGNED, -- When the content was uploaded in ms.
|
||||
upload_name VARCHAR(150), -- The name the media was uploaded with.
|
||||
media_length INTEGER, -- Length of the media in bytes.
|
||||
filesystem_id VARCHAR(150), -- The name used to store the media on disk.
|
||||
|
|
|
@ -16,7 +16,7 @@ CREATE TABLE IF NOT EXISTS presence(
|
|||
user_id VARCHAR(150) NOT NULL,
|
||||
state VARCHAR(20),
|
||||
status_msg VARCHAR(150),
|
||||
mtime BIGINT -- miliseconds since last state change
|
||||
mtime BIGINT UNSIGNED -- miliseconds since last state change
|
||||
);
|
||||
|
||||
-- For each of /my/ users which possibly-remote users are allowed to see their
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
CREATE TABLE IF NOT EXISTS received_transactions(
|
||||
transaction_id VARCHAR(150),
|
||||
origin VARCHAR(150),
|
||||
ts BIGINT,
|
||||
ts BIGINT UNSIGNED,
|
||||
response_code INTEGER,
|
||||
response_json BLOB,
|
||||
has_been_referenced BOOL default 0, -- Whether thishas been referenced by a prev_tx
|
||||
|
@ -34,7 +34,7 @@ CREATE TABLE IF NOT EXISTS sent_transactions(
|
|||
destination VARCHAR(150),
|
||||
response_code INTEGER DEFAULT 0,
|
||||
response_json BLOB,
|
||||
ts BIGINT
|
||||
ts BIGINT UNSIGNED
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS sent_transaction_dest ON sent_transactions(destination);
|
||||
|
@ -58,6 +58,6 @@ CREATE INDEX IF NOT EXISTS transaction_id_to_pdu_dest ON transaction_id_to_pdu(d
|
|||
-- To track destination health
|
||||
CREATE TABLE IF NOT EXISTS destinations(
|
||||
destination VARCHAR(150) PRIMARY KEY,
|
||||
retry_last_ts BIGINT,
|
||||
retry_last_ts BIGINT UNSIGNED,
|
||||
retry_interval INTEGER
|
||||
);
|
||||
|
|
|
@ -16,7 +16,7 @@ CREATE TABLE IF NOT EXISTS users(
|
|||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
name VARCHAR(150),
|
||||
password_hash VARCHAR(150),
|
||||
creation_ts BIGINT,
|
||||
creation_ts BIGINT UNSIGNED,
|
||||
admin BOOL DEFAULT 0 NOT NULL,
|
||||
UNIQUE(name)
|
||||
);
|
||||
|
@ -26,7 +26,7 @@ CREATE TABLE IF NOT EXISTS access_tokens(
|
|||
user_id VARCHAR(150) NOT NULL,
|
||||
device_id VARCHAR(150),
|
||||
token VARCHAR(150) NOT NULL,
|
||||
last_used BIGINT,
|
||||
last_used BIGINT UNSIGNED,
|
||||
UNIQUE(token)
|
||||
);
|
||||
|
||||
|
@ -36,7 +36,7 @@ CREATE TABLE IF NOT EXISTS user_ips (
|
|||
device_id VARCHAR(150),
|
||||
ip VARCHAR(150) NOT NULL,
|
||||
user_agent VARCHAR(150) NOT NULL,
|
||||
last_seen BIGINT NOT NULL,
|
||||
last_seen BIGINT UNSIGNED NOT NULL,
|
||||
UNIQUE (user, access_token, ip, user_agent)
|
||||
);
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
*/
|
||||
|
||||
CREATE TABLE IF NOT EXISTS application_services(
|
||||
id BIGINT PRIMARY KEY,
|
||||
id BIGINT UNSIGNED PRIMARY KEY,
|
||||
url VARCHAR(150),
|
||||
token VARCHAR(150),
|
||||
hs_token VARCHAR(150),
|
||||
|
@ -23,8 +23,8 @@ CREATE TABLE IF NOT EXISTS application_services(
|
|||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS application_services_regex(
|
||||
id BIGINT PRIMARY KEY,
|
||||
as_id BIGINT NOT NULL,
|
||||
id BIGINT UNSIGNED PRIMARY KEY,
|
||||
as_id BIGINT UNSIGNED NOT NULL,
|
||||
namespace INTEGER, /* enum[room_id|room_alias|user_id] */
|
||||
regex VARCHAR(150),
|
||||
FOREIGN KEY(as_id) REFERENCES application_services(id)
|
||||
|
|
|
@ -57,7 +57,7 @@ CREATE INDEX IF NOT EXISTS room_depth_room ON room_depth(room_id);
|
|||
create TABLE IF NOT EXISTS event_destinations(
|
||||
event_id VARCHAR(150) NOT NULL,
|
||||
destination VARCHAR(150) NOT NULL,
|
||||
delivered_ts BIGINT DEFAULT 0, -- or 0 if not delivered
|
||||
delivered_ts BIGINT UNSIGNED DEFAULT 0, -- or 0 if not delivered
|
||||
UNIQUE (event_id, destination)
|
||||
);
|
||||
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
*/
|
||||
|
||||
CREATE TABLE IF NOT EXISTS events(
|
||||
stream_ordering BIGINT PRIMARY KEY,
|
||||
topological_ordering BIGINT NOT NULL,
|
||||
stream_ordering BIGINT UNSIGNED PRIMARY KEY,
|
||||
topological_ordering BIGINT UNSIGNED NOT NULL,
|
||||
event_id VARCHAR(150) NOT NULL,
|
||||
type VARCHAR(150) NOT NULL,
|
||||
room_id VARCHAR(150) NOT NULL,
|
||||
|
@ -23,7 +23,7 @@ CREATE TABLE IF NOT EXISTS events(
|
|||
unrecognized_keys BLOB,
|
||||
processed BOOL NOT NULL,
|
||||
outlier BOOL NOT NULL,
|
||||
depth BIGINT DEFAULT 0 NOT NULL,
|
||||
depth BIGINT UNSIGNED DEFAULT 0 NOT NULL,
|
||||
UNIQUE (event_id)
|
||||
);
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ CREATE TABLE IF NOT EXISTS server_tls_certificates(
|
|||
server_name VARCHAR(150), -- Server name.
|
||||
fingerprint VARCHAR(150), -- Certificate fingerprint.
|
||||
from_server VARCHAR(150), -- Which key server the certificate was fetched from.
|
||||
ts_added_ms BIGINT, -- When the certifcate was added.
|
||||
ts_added_ms BIGINT UNSIGNED, -- When the certifcate was added.
|
||||
tls_certificate BLOB, -- DER encoded x509 certificate.
|
||||
UNIQUE (server_name, fingerprint)
|
||||
);
|
||||
|
@ -25,7 +25,7 @@ CREATE TABLE IF NOT EXISTS server_signature_keys(
|
|||
server_name VARCHAR(150), -- Server name.
|
||||
key_id VARCHAR(150), -- Key version.
|
||||
from_server VARCHAR(150), -- Which key server the key was fetched form.
|
||||
ts_added_ms BIGINT, -- When the key was added.
|
||||
ts_added_ms BIGINT UNSIGNED, -- When the key was added.
|
||||
verify_key BLOB, -- NACL verification key.
|
||||
UNIQUE (server_name, key_id)
|
||||
);
|
||||
|
|
|
@ -17,7 +17,7 @@ CREATE TABLE IF NOT EXISTS local_media_repository (
|
|||
media_id VARCHAR(150), -- The id used to refer to the media.
|
||||
media_type VARCHAR(150), -- The MIME-type of the media.
|
||||
media_length INTEGER, -- Length of the media in bytes.
|
||||
created_ts BIGINT, -- When the content was uploaded in ms.
|
||||
created_ts BIGINT UNSIGNED, -- When the content was uploaded in ms.
|
||||
upload_name VARCHAR(150), -- The name the media was uploaded with.
|
||||
user_id VARCHAR(150), -- The user who uploaded the file.
|
||||
UNIQUE (media_id)
|
||||
|
@ -42,7 +42,7 @@ CREATE TABLE IF NOT EXISTS remote_media_cache (
|
|||
media_origin VARCHAR(150), -- The remote HS the media came from.
|
||||
media_id VARCHAR(150), -- The id used to refer to the media on that server.
|
||||
media_type VARCHAR(150), -- The MIME-type of the media.
|
||||
created_ts BIGINT, -- When the content was uploaded in ms.
|
||||
created_ts BIGINT UNSIGNED, -- When the content was uploaded in ms.
|
||||
upload_name VARCHAR(150), -- The name the media was uploaded with.
|
||||
media_length INTEGER, -- Length of the media in bytes.
|
||||
filesystem_id VARCHAR(150), -- The name used to store the media on disk.
|
||||
|
|
|
@ -16,7 +16,7 @@ CREATE TABLE IF NOT EXISTS presence(
|
|||
user_id VARCHAR(150) NOT NULL,
|
||||
state VARCHAR(20),
|
||||
status_msg VARCHAR(150),
|
||||
mtime BIGINT, -- miliseconds since last state change
|
||||
mtime BIGINT UNSIGNED, -- miliseconds since last state change
|
||||
UNIQUE (user_id)
|
||||
);
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ CREATE TABLE IF NOT EXISTS rejections(
|
|||
|
||||
-- Push notification endpoints that users have configured
|
||||
CREATE TABLE IF NOT EXISTS pushers (
|
||||
id BIGINT PRIMARY KEY,
|
||||
id BIGINT UNSIGNED PRIMARY KEY,
|
||||
user_name VARCHAR(150) NOT NULL,
|
||||
profile_tag VARCHAR(32) NOT NULL,
|
||||
kind VARCHAR(8) NOT NULL,
|
||||
|
@ -30,17 +30,17 @@ CREATE TABLE IF NOT EXISTS pushers (
|
|||
app_display_name VARCHAR(64) NOT NULL,
|
||||
device_display_name VARCHAR(128) NOT NULL,
|
||||
pushkey VARBINARY(512) NOT NULL,
|
||||
ts BIGINT NOT NULL,
|
||||
ts BIGINT UNSIGNED NOT NULL,
|
||||
lang VARCHAR(8),
|
||||
data BLOB,
|
||||
last_token TEXT,
|
||||
last_success BIGINT,
|
||||
failing_since BIGINT,
|
||||
last_success BIGINT UNSIGNED,
|
||||
failing_since BIGINT UNSIGNED,
|
||||
UNIQUE (app_id, pushkey)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS push_rules (
|
||||
id BIGINT PRIMARY KEY,
|
||||
id BIGINT UNSIGNED PRIMARY KEY,
|
||||
user_name VARCHAR(150) NOT NULL,
|
||||
rule_id VARCHAR(150) NOT NULL,
|
||||
priority_class TINYINT NOT NULL,
|
||||
|
@ -54,7 +54,7 @@ CREATE INDEX IF NOT EXISTS push_rules_user_name on push_rules (user_name);
|
|||
|
||||
CREATE TABLE IF NOT EXISTS user_filters(
|
||||
user_id VARCHAR(150),
|
||||
filter_id BIGINT,
|
||||
filter_id BIGINT UNSIGNED,
|
||||
filter_json BLOB
|
||||
);
|
||||
|
||||
|
@ -63,7 +63,7 @@ CREATE INDEX IF NOT EXISTS user_filters_by_user_id_filter_id ON user_filters(
|
|||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS push_rules_enable (
|
||||
id BIGINT PRIMARY KEY,
|
||||
id BIGINT UNSIGNED PRIMARY KEY,
|
||||
user_name VARCHAR(150) NOT NULL,
|
||||
rule_id VARCHAR(150) NOT NULL,
|
||||
enabled TINYINT,
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
CREATE TABLE IF NOT EXISTS received_transactions(
|
||||
transaction_id VARCHAR(150),
|
||||
origin VARCHAR(150),
|
||||
ts BIGINT,
|
||||
ts BIGINT UNSIGNED,
|
||||
response_code INTEGER,
|
||||
response_json BLOB,
|
||||
has_been_referenced BOOL default 0, -- Whether thishas been referenced by a prev_tx
|
||||
|
@ -29,12 +29,12 @@ CREATE INDEX IF NOT EXISTS transactions_have_ref ON received_transactions(origin
|
|||
-- Stores what transactions we've sent, what their response was (if we got one) and whether we have
|
||||
-- since referenced the transaction in another outgoing transaction
|
||||
CREATE TABLE IF NOT EXISTS sent_transactions(
|
||||
id BIGINT PRIMARY KEY, -- This is used to apply insertion ordering
|
||||
id BIGINT UNSIGNED PRIMARY KEY, -- This is used to apply insertion ordering
|
||||
transaction_id VARCHAR(150),
|
||||
destination VARCHAR(150),
|
||||
response_code INTEGER DEFAULT 0,
|
||||
response_json BLOB,
|
||||
ts BIGINT
|
||||
ts BIGINT UNSIGNED
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS sent_transaction_dest ON sent_transactions(destination);
|
||||
|
@ -58,6 +58,6 @@ CREATE INDEX IF NOT EXISTS transaction_id_to_pdu_dest ON transaction_id_to_pdu(d
|
|||
-- To track destination health
|
||||
CREATE TABLE IF NOT EXISTS destinations(
|
||||
destination VARCHAR(150) PRIMARY KEY,
|
||||
retry_last_ts BIGINT,
|
||||
retry_last_ts BIGINT UNSIGNED,
|
||||
retry_interval INTEGER
|
||||
);
|
||||
|
|
|
@ -15,17 +15,17 @@
|
|||
CREATE TABLE IF NOT EXISTS users(
|
||||
name VARCHAR(150),
|
||||
password_hash VARCHAR(150),
|
||||
creation_ts BIGINT,
|
||||
creation_ts BIGINT UNSIGNED,
|
||||
admin BOOL DEFAULT 0 NOT NULL,
|
||||
UNIQUE(name)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS access_tokens(
|
||||
id BIGINT PRIMARY KEY,
|
||||
id BIGINT UNSIGNED PRIMARY KEY,
|
||||
user_id VARCHAR(150) NOT NULL,
|
||||
device_id VARCHAR(150),
|
||||
token VARCHAR(150) NOT NULL,
|
||||
last_used BIGINT,
|
||||
last_used BIGINT UNSIGNED,
|
||||
UNIQUE(token)
|
||||
);
|
||||
|
||||
|
@ -35,7 +35,7 @@ CREATE TABLE IF NOT EXISTS user_ips (
|
|||
device_id VARCHAR(150),
|
||||
ip VARCHAR(150) NOT NULL,
|
||||
user_agent VARCHAR(150) NOT NULL,
|
||||
last_seen BIGINT NOT NULL
|
||||
last_seen BIGINT UNSIGNED NOT NULL
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS user_ips_user ON user_ips(user);
|
||||
|
|
Loading…
Reference in a new issue