2019-07-25 05:35:09 +00:00
|
|
|
CREATE TABLE IF NOT EXISTS settings (
|
|
|
|
type VARCHAR PRIMARY KEY,
|
|
|
|
value BLOB
|
|
|
|
) WITHOUT ROWID;
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS accounts (
|
|
|
|
address VARCHAR PRIMARY KEY,
|
|
|
|
wallet BOOLEAN,
|
|
|
|
chat BOOLEAN,
|
|
|
|
type TEXT,
|
|
|
|
storage TEXT,
|
|
|
|
pubkey BLOB,
|
|
|
|
path TEXT,
|
|
|
|
name TEXT,
|
|
|
|
color TEXT
|
|
|
|
) WITHOUT ROWID;
|
|
|
|
|
|
|
|
CREATE UNIQUE INDEX unique_wallet_address ON accounts (wallet) WHERE (wallet);
|
|
|
|
CREATE UNIQUE INDEX unique_chat_address ON accounts (chat) WHERE (chat);
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS browsers (
|
|
|
|
id TEXT PRIMARY KEY,
|
|
|
|
name TEXT NOT NULL,
|
|
|
|
timestamp USGIGNED BIGINT,
|
|
|
|
dapp BOOLEAN DEFAULT false,
|
|
|
|
historyIndex UNSIGNED INT
|
|
|
|
) WITHOUT ROWID;
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS browsers_history (
|
|
|
|
browser_id TEXT NOT NULL,
|
|
|
|
history TEXT,
|
|
|
|
FOREIGN KEY(browser_id) REFERENCES browsers(id) ON DELETE CASCADE
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS dapps (
|
|
|
|
name TEXT PRIMARY KEY
|
|
|
|
) WITHOUT ROWID;
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS permissions (
|
|
|
|
dapp_name TEXT NOT NULL,
|
|
|
|
permission TEXT NOT NULL,
|
|
|
|
FOREIGN KEY(dapp_name) REFERENCES dapps(name) ON DELETE CASCADE
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS transfers (
|
2019-08-08 08:15:07 +00:00
|
|
|
network_id UNSIGNED BIGINT NOT NULL,
|
|
|
|
hash VARCHAR NOT NULL,
|
2019-07-25 05:35:09 +00:00
|
|
|
address VARCHAR NOT NULL,
|
|
|
|
blk_hash VARCHAR NOT NULL,
|
|
|
|
tx BLOB,
|
|
|
|
sender VARCHAR NOT NULL,
|
|
|
|
receipt BLOB,
|
|
|
|
log BLOB,
|
|
|
|
type VARCHAR NOT NULL,
|
2019-08-08 08:15:07 +00:00
|
|
|
FOREIGN KEY(network_id,blk_hash) REFERENCES blocks(network_id,hash) ON DELETE CASCADE,
|
|
|
|
CONSTRAINT unique_transfer_per_address_per_network UNIQUE (hash,address,network_id)
|
2019-07-25 05:35:09 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS blocks (
|
2019-08-08 08:15:07 +00:00
|
|
|
network_id UNSIGNED BIGINT NOT NULL,
|
|
|
|
hash VARCHAR NOT NULL,
|
|
|
|
number BIGINT NOT NULL,
|
2019-07-25 05:35:09 +00:00
|
|
|
timestamp UNSIGNED BIGINT NOT NULL,
|
2019-08-08 08:15:07 +00:00
|
|
|
head BOOL DEFAULT FALSE,
|
|
|
|
CONSTRAINT unique_block_per_network UNIQUE (network_id,hash)
|
|
|
|
CONSTRAINT unique_block_number_per_network UNIQUE (network_id,number)
|
|
|
|
);
|
2019-07-25 05:35:09 +00:00
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS accounts_to_blocks (
|
2019-08-08 08:15:07 +00:00
|
|
|
network_id UNSIGNED BIGINT NOT NULL,
|
2019-07-25 05:35:09 +00:00
|
|
|
address VARCHAR NOT NULL,
|
|
|
|
blk_number BIGINT NOT NULL,
|
|
|
|
sync INT,
|
2019-08-08 08:15:07 +00:00
|
|
|
FOREIGN KEY(network_id,blk_number) REFERENCES blocks(network_id,number) ON DELETE CASCADE,
|
|
|
|
CONSTRAINT unique_mapping_for_account_to_block_per_network UNIQUE (address,blk_number,network_id)
|
2019-07-25 05:35:09 +00:00
|
|
|
);
|
2019-09-04 06:25:33 +00:00
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS mailservers (
|
|
|
|
id VARCHAR PRIMARY KEY,
|
|
|
|
name VARCHAR NOT NULL,
|
|
|
|
address VARCHAR NOT NULL,
|
|
|
|
password VARCHAR,
|
|
|
|
fleet VARCHAR NOT NULL
|
2019-09-04 18:23:17 +00:00
|
|
|
) WITHOUT ROWID;
|
2019-09-04 10:04:17 +00:00
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS mailserver_request_gaps (
|
2019-09-04 18:23:17 +00:00
|
|
|
gap_from UNSIGNED INTEGER NOT NULL,
|
|
|
|
gap_to UNSIGNED INTEGER NOT NULL,
|
|
|
|
id TEXT PRIMARY KEY,
|
|
|
|
chat_id TEXT NOT NULL
|
|
|
|
) WITHOUT ROWID;
|
2019-09-04 10:04:17 +00:00
|
|
|
|
|
|
|
CREATE INDEX mailserver_request_gaps_chat_id_idx ON mailserver_request_gaps (chat_id);
|
2019-09-04 18:23:17 +00:00
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS mailserver_topics (
|
|
|
|
topic VARCHAR PRIMARY KEY,
|
|
|
|
chat_ids VARCHAR,
|
|
|
|
last_request INTEGER DEFAULT 1
|
|
|
|
) WITHOUT ROWID;
|