status-go/protocol/pushnotificationclient/migrations/sql/1593601729_initial_schema.u...

55 lines
1.7 KiB
MySQL
Raw Normal View History

CREATE TABLE IF NOT EXISTS push_notification_client_servers (
public_key BLOB NOT NULL,
registered BOOLEAN DEFAULT FALSE,
registered_at INT NOT NULL DEFAULT 0,
last_retried_at INT NOT NULL DEFAULT 0,
retry_count INT NOT NULL DEFAULT 0,
access_token TEXT,
UNIQUE(public_key) ON CONFLICT REPLACE
);
CREATE TABLE IF NOT EXISTS push_notification_client_queries (
public_key BLOB NOT NULL,
queried_at INT NOT NULL,
query_id BLOB NOT NULL,
UNIQUE(public_key,query_id) ON CONFLICT REPLACE
);
CREATE TABLE IF NOT EXISTS push_notification_client_info (
public_key BLOB NOT NULL,
server_public_key BLOB NOT NULL,
installation_id TEXT NOT NULL,
access_token TEXT NOT NULL,
retrieved_at INT NOT NULL,
2020-07-17 11:41:49 +00:00
version INT NOT NULL,
UNIQUE(public_key, installation_id, server_public_key) ON CONFLICT REPLACE
);
CREATE TABLE IF NOT EXISTS push_notification_client_tracked_messages (
message_id BLOB NOT NULL,
chat_id TEXT NOT NULL,
tracked_at INT NOT NULL,
UNIQUE(message_id) ON CONFLICT IGNORE
);
CREATE TABLE IF NOT EXISTS push_notification_client_sent_notifications (
message_id BLOB NOT NULL,
public_key BLOB NOT NULL,
2020-07-20 10:01:42 +00:00
hashed_public_key BLOB NOT NULL,
installation_id TEXT NOT NULL,
last_tried_at INT NOT NULL,
retry_count INT NOT NULL DEFAULT 0,
2020-07-20 10:01:42 +00:00
success BOOLEAN NOT NULL DEFAULT FALSE,
error INT NOT NULL DEFAULT 0,
UNIQUE(message_id, public_key, installation_id) ON CONFLICT REPLACE
);
CREATE TABLE IF NOT EXISTS push_notification_client_registrations (
registration BLOB NOT NULL,
2020-07-15 08:22:43 +00:00
contact_ids BLOB,
synthetic_id INT NOT NULL DEFAULT 0,
UNIQUE(synthetic_id) ON CONFLICT REPLACE
);
CREATE INDEX idx_push_notification_client_info_public_key ON push_notification_client_info(public_key, installation_id);