2018-12-05 09:35:50 +00:00
|
|
|
-- AUTOGENERATED BY gopkg.in/spacemonkeygo/dbx.v1
|
|
|
|
-- DO NOT EDIT
|
2018-12-18 17:18:42 +00:00
|
|
|
CREATE TABLE accounting_rollups (
|
|
|
|
id INTEGER NOT NULL,
|
2019-01-16 19:30:33 +00:00
|
|
|
node_id BLOB NOT NULL,
|
2018-12-18 17:18:42 +00:00
|
|
|
start_time TIMESTAMP NOT NULL,
|
2019-01-16 19:30:33 +00:00
|
|
|
put_total INTEGER NOT NULL,
|
|
|
|
get_total INTEGER NOT NULL,
|
|
|
|
get_audit_total INTEGER NOT NULL,
|
|
|
|
get_repair_total INTEGER NOT NULL,
|
|
|
|
put_repair_total INTEGER NOT NULL,
|
|
|
|
at_rest_total REAL NOT NULL,
|
2018-12-18 17:18:42 +00:00
|
|
|
PRIMARY KEY ( id )
|
|
|
|
);
|
|
|
|
CREATE TABLE accounting_timestamps (
|
|
|
|
name TEXT NOT NULL,
|
|
|
|
value TIMESTAMP NOT NULL,
|
|
|
|
PRIMARY KEY ( name )
|
|
|
|
);
|
2019-03-22 18:54:22 +00:00
|
|
|
CREATE TABLE bucket_bandwidth_rollups (
|
2019-04-02 19:21:18 +01:00
|
|
|
bucket_name BLOB NOT NULL,
|
|
|
|
project_id BLOB NOT NULL,
|
2019-03-22 18:54:22 +00:00
|
|
|
interval_start TIMESTAMP NOT NULL,
|
|
|
|
interval_seconds INTEGER NOT NULL,
|
|
|
|
action INTEGER NOT NULL,
|
|
|
|
inline INTEGER NOT NULL,
|
|
|
|
allocated INTEGER NOT NULL,
|
|
|
|
settled INTEGER NOT NULL,
|
2019-04-02 19:21:18 +01:00
|
|
|
PRIMARY KEY ( bucket_name, project_id, interval_start, action )
|
2019-03-22 18:54:22 +00:00
|
|
|
);
|
2019-03-28 02:46:49 +00:00
|
|
|
CREATE TABLE bucket_storage_tallies (
|
2019-04-02 19:21:18 +01:00
|
|
|
bucket_name BLOB NOT NULL,
|
|
|
|
project_id BLOB NOT NULL,
|
2019-03-22 18:54:22 +00:00
|
|
|
interval_start TIMESTAMP NOT NULL,
|
|
|
|
inline INTEGER NOT NULL,
|
|
|
|
remote INTEGER NOT NULL,
|
2019-03-28 02:46:49 +00:00
|
|
|
remote_segments_count INTEGER NOT NULL,
|
|
|
|
inline_segments_count INTEGER NOT NULL,
|
|
|
|
object_count INTEGER NOT NULL,
|
|
|
|
metadata_size INTEGER NOT NULL,
|
2019-04-02 19:21:18 +01:00
|
|
|
PRIMARY KEY ( bucket_name, project_id, interval_start )
|
2019-03-22 18:54:22 +00:00
|
|
|
);
|
2019-03-06 15:54:48 +00:00
|
|
|
CREATE TABLE bucket_usages (
|
|
|
|
id BLOB NOT NULL,
|
|
|
|
bucket_id BLOB NOT NULL,
|
|
|
|
rollup_end_time TIMESTAMP NOT NULL,
|
|
|
|
remote_stored_data INTEGER NOT NULL,
|
|
|
|
inline_stored_data INTEGER NOT NULL,
|
|
|
|
remote_segments INTEGER NOT NULL,
|
|
|
|
inline_segments INTEGER NOT NULL,
|
|
|
|
objects INTEGER NOT NULL,
|
|
|
|
metadata_size INTEGER NOT NULL,
|
|
|
|
repair_egress INTEGER NOT NULL,
|
|
|
|
get_egress INTEGER NOT NULL,
|
|
|
|
audit_egress INTEGER NOT NULL,
|
2019-03-26 10:34:30 +00:00
|
|
|
PRIMARY KEY ( id )
|
2019-03-06 15:54:48 +00:00
|
|
|
);
|
2019-02-07 19:22:49 +00:00
|
|
|
CREATE TABLE certRecords (
|
|
|
|
publickey BLOB NOT NULL,
|
|
|
|
id BLOB NOT NULL,
|
|
|
|
update_at TIMESTAMP NOT NULL,
|
2019-08-02 18:47:35 +01:00
|
|
|
PRIMARY KEY ( publickey )
|
2019-02-07 19:22:49 +00:00
|
|
|
);
|
2018-12-21 15:11:19 +00:00
|
|
|
CREATE TABLE injuredsegments (
|
2019-07-11 18:26:07 +01:00
|
|
|
path BLOB NOT NULL,
|
2019-04-16 19:14:09 +01:00
|
|
|
data BLOB NOT NULL,
|
|
|
|
attempted TIMESTAMP,
|
|
|
|
PRIMARY KEY ( path )
|
2018-12-21 15:11:19 +00:00
|
|
|
);
|
2018-12-10 19:08:45 +00:00
|
|
|
CREATE TABLE irreparabledbs (
|
|
|
|
segmentpath BLOB NOT NULL,
|
|
|
|
segmentdetail BLOB NOT NULL,
|
|
|
|
pieces_lost_count INTEGER NOT NULL,
|
|
|
|
seg_damaged_unix_sec INTEGER NOT NULL,
|
|
|
|
repair_attempt_count INTEGER NOT NULL,
|
|
|
|
PRIMARY KEY ( segmentpath )
|
|
|
|
);
|
2018-12-14 20:17:30 +00:00
|
|
|
CREATE TABLE nodes (
|
|
|
|
id BLOB NOT NULL,
|
2019-03-29 08:53:43 +00:00
|
|
|
address TEXT NOT NULL,
|
2019-06-24 16:33:18 +01:00
|
|
|
last_net TEXT NOT NULL,
|
2019-03-29 08:53:43 +00:00
|
|
|
protocol INTEGER NOT NULL,
|
|
|
|
type INTEGER NOT NULL,
|
|
|
|
email TEXT NOT NULL,
|
|
|
|
wallet TEXT NOT NULL,
|
|
|
|
free_bandwidth INTEGER NOT NULL,
|
|
|
|
free_disk INTEGER NOT NULL,
|
2019-04-10 07:04:24 +01:00
|
|
|
major INTEGER NOT NULL,
|
|
|
|
minor INTEGER NOT NULL,
|
|
|
|
patch INTEGER NOT NULL,
|
|
|
|
hash TEXT NOT NULL,
|
|
|
|
timestamp TIMESTAMP NOT NULL,
|
|
|
|
release INTEGER NOT NULL,
|
2019-03-29 08:53:43 +00:00
|
|
|
latency_90 INTEGER NOT NULL,
|
2018-12-14 20:17:30 +00:00
|
|
|
audit_success_count INTEGER NOT NULL,
|
|
|
|
total_audit_count INTEGER NOT NULL,
|
|
|
|
uptime_success_count INTEGER NOT NULL,
|
|
|
|
total_uptime_count INTEGER NOT NULL,
|
|
|
|
created_at TIMESTAMP NOT NULL,
|
|
|
|
updated_at TIMESTAMP NOT NULL,
|
2019-03-29 08:53:43 +00:00
|
|
|
last_contact_success TIMESTAMP NOT NULL,
|
|
|
|
last_contact_failure TIMESTAMP NOT NULL,
|
2019-05-16 15:11:15 +01:00
|
|
|
contained INTEGER NOT NULL,
|
2019-06-18 10:14:31 +01:00
|
|
|
disqualified TIMESTAMP,
|
2019-06-18 14:45:02 +01:00
|
|
|
audit_reputation_alpha REAL NOT NULL,
|
|
|
|
audit_reputation_beta REAL NOT NULL,
|
|
|
|
uptime_reputation_alpha REAL NOT NULL,
|
|
|
|
uptime_reputation_beta REAL NOT NULL,
|
2018-12-14 20:17:30 +00:00
|
|
|
PRIMARY KEY ( id )
|
|
|
|
);
|
2019-05-22 22:41:55 +01:00
|
|
|
CREATE TABLE offers (
|
|
|
|
id INTEGER NOT NULL,
|
|
|
|
name TEXT NOT NULL,
|
|
|
|
description TEXT NOT NULL,
|
2019-06-04 20:17:01 +01:00
|
|
|
award_credit_in_cents INTEGER NOT NULL,
|
|
|
|
invitee_credit_in_cents INTEGER NOT NULL,
|
2019-07-12 15:19:38 +01:00
|
|
|
award_credit_duration_days INTEGER,
|
|
|
|
invitee_credit_duration_days INTEGER,
|
|
|
|
redeemable_cap INTEGER,
|
2019-06-04 20:17:01 +01:00
|
|
|
expires_at TIMESTAMP NOT NULL,
|
2019-05-22 22:41:55 +01:00
|
|
|
created_at TIMESTAMP NOT NULL,
|
|
|
|
status INTEGER NOT NULL,
|
2019-06-04 20:17:01 +01:00
|
|
|
type INTEGER NOT NULL,
|
2019-05-22 22:41:55 +01:00
|
|
|
PRIMARY KEY ( id )
|
|
|
|
);
|
2019-05-16 15:11:15 +01:00
|
|
|
CREATE TABLE pending_audits (
|
|
|
|
node_id BLOB NOT NULL,
|
|
|
|
piece_id BLOB NOT NULL,
|
|
|
|
stripe_index INTEGER NOT NULL,
|
|
|
|
share_size INTEGER NOT NULL,
|
|
|
|
expected_share_hash BLOB NOT NULL,
|
|
|
|
reverify_count INTEGER NOT NULL,
|
2019-07-18 19:08:15 +01:00
|
|
|
path BLOB NOT NULL,
|
2019-05-16 15:11:15 +01:00
|
|
|
PRIMARY KEY ( node_id )
|
|
|
|
);
|
2019-01-16 20:23:28 +00:00
|
|
|
CREATE TABLE projects (
|
|
|
|
id BLOB NOT NULL,
|
|
|
|
name TEXT NOT NULL,
|
|
|
|
description TEXT NOT NULL,
|
2019-05-28 16:36:52 +01:00
|
|
|
usage_limit INTEGER NOT NULL,
|
2019-07-12 18:59:19 +01:00
|
|
|
partner_id BLOB,
|
2019-08-07 13:28:13 +01:00
|
|
|
owner_id BLOB NOT NULL,
|
2019-01-16 20:23:28 +00:00
|
|
|
created_at TIMESTAMP NOT NULL,
|
|
|
|
PRIMARY KEY ( id )
|
|
|
|
);
|
2019-03-19 17:55:43 +00:00
|
|
|
CREATE TABLE registration_tokens (
|
|
|
|
secret BLOB NOT NULL,
|
|
|
|
owner_id BLOB,
|
|
|
|
project_limit INTEGER NOT NULL,
|
|
|
|
created_at TIMESTAMP NOT NULL,
|
|
|
|
PRIMARY KEY ( secret ),
|
|
|
|
UNIQUE ( owner_id )
|
|
|
|
);
|
2019-05-13 16:53:52 +01:00
|
|
|
CREATE TABLE reset_password_tokens (
|
|
|
|
secret BLOB NOT NULL,
|
|
|
|
owner_id BLOB NOT NULL,
|
|
|
|
created_at TIMESTAMP NOT NULL,
|
|
|
|
PRIMARY KEY ( secret ),
|
|
|
|
UNIQUE ( owner_id )
|
|
|
|
);
|
2019-03-22 18:54:22 +00:00
|
|
|
CREATE TABLE serial_numbers (
|
|
|
|
id INTEGER NOT NULL,
|
|
|
|
serial_number BLOB NOT NULL,
|
|
|
|
bucket_id BLOB NOT NULL,
|
|
|
|
expires_at TIMESTAMP NOT NULL,
|
2019-03-26 10:34:30 +00:00
|
|
|
PRIMARY KEY ( id )
|
2019-03-22 18:54:22 +00:00
|
|
|
);
|
|
|
|
CREATE TABLE storagenode_bandwidth_rollups (
|
|
|
|
storagenode_id BLOB NOT NULL,
|
|
|
|
interval_start TIMESTAMP NOT NULL,
|
|
|
|
interval_seconds INTEGER NOT NULL,
|
|
|
|
action INTEGER NOT NULL,
|
|
|
|
allocated INTEGER NOT NULL,
|
|
|
|
settled INTEGER NOT NULL,
|
2019-03-26 10:34:30 +00:00
|
|
|
PRIMARY KEY ( storagenode_id, interval_start, action )
|
2019-03-22 18:54:22 +00:00
|
|
|
);
|
2019-03-28 02:46:49 +00:00
|
|
|
CREATE TABLE storagenode_storage_tallies (
|
2019-05-10 20:05:42 +01:00
|
|
|
id INTEGER NOT NULL,
|
|
|
|
node_id BLOB NOT NULL,
|
|
|
|
interval_end_time TIMESTAMP NOT NULL,
|
|
|
|
data_total REAL NOT NULL,
|
|
|
|
PRIMARY KEY ( id )
|
2019-03-22 18:54:22 +00:00
|
|
|
);
|
2019-01-16 20:23:28 +00:00
|
|
|
CREATE TABLE users (
|
|
|
|
id BLOB NOT NULL,
|
2019-06-06 17:07:14 +01:00
|
|
|
email TEXT NOT NULL,
|
2019-03-27 12:33:32 +00:00
|
|
|
full_name TEXT NOT NULL,
|
|
|
|
short_name TEXT,
|
2019-01-16 20:23:28 +00:00
|
|
|
password_hash BLOB NOT NULL,
|
2019-02-11 10:33:56 +00:00
|
|
|
status INTEGER NOT NULL,
|
2019-07-12 18:59:19 +01:00
|
|
|
partner_id BLOB,
|
2019-01-16 20:23:28 +00:00
|
|
|
created_at TIMESTAMP NOT NULL,
|
2019-02-11 10:33:56 +00:00
|
|
|
PRIMARY KEY ( id )
|
2019-01-16 20:23:28 +00:00
|
|
|
);
|
2019-06-05 17:06:14 +01:00
|
|
|
CREATE TABLE value_attributions (
|
2019-06-13 13:28:55 +01:00
|
|
|
project_id BLOB NOT NULL,
|
|
|
|
bucket_name BLOB NOT NULL,
|
2019-06-05 17:06:14 +01:00
|
|
|
partner_id BLOB NOT NULL,
|
|
|
|
last_updated TIMESTAMP NOT NULL,
|
2019-06-13 13:28:55 +01:00
|
|
|
PRIMARY KEY ( project_id, bucket_name )
|
2019-06-05 17:06:14 +01:00
|
|
|
);
|
2019-01-16 20:23:28 +00:00
|
|
|
CREATE TABLE api_keys (
|
|
|
|
id BLOB NOT NULL,
|
|
|
|
project_id BLOB NOT NULL REFERENCES projects( id ) ON DELETE CASCADE,
|
2019-05-24 17:51:27 +01:00
|
|
|
head BLOB NOT NULL,
|
2019-01-16 20:23:28 +00:00
|
|
|
name TEXT NOT NULL,
|
2019-05-24 17:51:27 +01:00
|
|
|
secret BLOB NOT NULL,
|
2019-07-12 18:59:19 +01:00
|
|
|
partner_id BLOB,
|
2019-01-16 20:23:28 +00:00
|
|
|
created_at TIMESTAMP NOT NULL,
|
|
|
|
PRIMARY KEY ( id ),
|
2019-05-24 17:51:27 +01:00
|
|
|
UNIQUE ( head ),
|
2019-01-16 20:23:28 +00:00
|
|
|
UNIQUE ( name, project_id )
|
|
|
|
);
|
2019-07-03 23:03:56 +01:00
|
|
|
CREATE TABLE bucket_metainfos (
|
2019-07-01 21:45:21 +01:00
|
|
|
id BLOB NOT NULL,
|
|
|
|
project_id BLOB NOT NULL REFERENCES projects( id ),
|
|
|
|
name BLOB NOT NULL,
|
2019-07-12 18:59:19 +01:00
|
|
|
partner_id BLOB,
|
2019-07-01 21:45:21 +01:00
|
|
|
path_cipher INTEGER NOT NULL,
|
|
|
|
created_at TIMESTAMP NOT NULL,
|
|
|
|
default_segment_size INTEGER NOT NULL,
|
|
|
|
default_encryption_cipher_suite INTEGER NOT NULL,
|
|
|
|
default_encryption_block_size INTEGER NOT NULL,
|
|
|
|
default_redundancy_algorithm INTEGER NOT NULL,
|
|
|
|
default_redundancy_share_size INTEGER NOT NULL,
|
|
|
|
default_redundancy_required_shares INTEGER NOT NULL,
|
|
|
|
default_redundancy_repair_shares INTEGER NOT NULL,
|
|
|
|
default_redundancy_optimal_shares INTEGER NOT NULL,
|
|
|
|
default_redundancy_total_shares INTEGER NOT NULL,
|
|
|
|
PRIMARY KEY ( id ),
|
|
|
|
UNIQUE ( name, project_id )
|
|
|
|
);
|
2019-06-06 17:07:14 +01:00
|
|
|
CREATE TABLE project_invoice_stamps (
|
|
|
|
project_id BLOB NOT NULL REFERENCES projects( id ) ON DELETE CASCADE,
|
|
|
|
invoice_id BLOB NOT NULL,
|
|
|
|
start_date TIMESTAMP NOT NULL,
|
|
|
|
end_date TIMESTAMP NOT NULL,
|
|
|
|
created_at TIMESTAMP NOT NULL,
|
|
|
|
PRIMARY KEY ( project_id, start_date, end_date ),
|
|
|
|
UNIQUE ( invoice_id )
|
|
|
|
);
|
2019-01-16 20:23:28 +00:00
|
|
|
CREATE TABLE project_members (
|
|
|
|
member_id BLOB NOT NULL REFERENCES users( id ) ON DELETE CASCADE,
|
|
|
|
project_id BLOB NOT NULL REFERENCES projects( id ) ON DELETE CASCADE,
|
|
|
|
created_at TIMESTAMP NOT NULL,
|
|
|
|
PRIMARY KEY ( member_id, project_id )
|
|
|
|
);
|
2019-03-22 18:54:22 +00:00
|
|
|
CREATE TABLE used_serials (
|
|
|
|
serial_number_id INTEGER NOT NULL REFERENCES serial_numbers( id ) ON DELETE CASCADE,
|
|
|
|
storage_node_id BLOB NOT NULL,
|
2019-03-26 10:34:30 +00:00
|
|
|
PRIMARY KEY ( serial_number_id, storage_node_id )
|
2019-03-22 18:54:22 +00:00
|
|
|
);
|
2019-06-13 14:52:33 +01:00
|
|
|
CREATE TABLE user_credits (
|
|
|
|
id INTEGER NOT NULL,
|
2019-08-01 18:46:33 +01:00
|
|
|
user_id BLOB NOT NULL REFERENCES users( id ) ON DELETE CASCADE,
|
2019-06-13 14:52:33 +01:00
|
|
|
offer_id INTEGER NOT NULL REFERENCES offers( id ),
|
2019-08-01 18:46:33 +01:00
|
|
|
referred_by BLOB REFERENCES users( id ) ON DELETE SET NULL,
|
|
|
|
type TEXT NOT NULL,
|
2019-06-13 14:52:33 +01:00
|
|
|
credits_earned_in_cents INTEGER NOT NULL,
|
|
|
|
credits_used_in_cents INTEGER NOT NULL,
|
|
|
|
expires_at TIMESTAMP NOT NULL,
|
|
|
|
created_at TIMESTAMP NOT NULL,
|
|
|
|
PRIMARY KEY ( id )
|
|
|
|
);
|
2019-06-06 17:07:14 +01:00
|
|
|
CREATE TABLE user_payments (
|
|
|
|
user_id BLOB NOT NULL REFERENCES users( id ) ON DELETE CASCADE,
|
|
|
|
customer_id BLOB NOT NULL,
|
|
|
|
created_at TIMESTAMP NOT NULL,
|
|
|
|
PRIMARY KEY ( user_id ),
|
|
|
|
UNIQUE ( customer_id )
|
|
|
|
);
|
|
|
|
CREATE TABLE project_payments (
|
2019-07-10 21:29:26 +01:00
|
|
|
id BLOB NOT NULL,
|
2019-06-06 17:07:14 +01:00
|
|
|
project_id BLOB NOT NULL REFERENCES projects( id ) ON DELETE CASCADE,
|
|
|
|
payer_id BLOB NOT NULL REFERENCES user_payments( user_id ) ON DELETE CASCADE,
|
|
|
|
payment_method_id BLOB NOT NULL,
|
2019-07-10 21:29:26 +01:00
|
|
|
is_default INTEGER NOT NULL,
|
2019-06-06 17:07:14 +01:00
|
|
|
created_at TIMESTAMP NOT NULL,
|
2019-07-10 21:29:26 +01:00
|
|
|
PRIMARY KEY ( id )
|
2019-06-06 17:07:14 +01:00
|
|
|
);
|
2019-04-02 19:21:18 +01:00
|
|
|
CREATE INDEX bucket_name_project_id_interval_start_interval_seconds ON bucket_bandwidth_rollups ( bucket_name, project_id, interval_start, interval_seconds );
|
2019-03-26 10:34:30 +00:00
|
|
|
CREATE UNIQUE INDEX bucket_id_rollup ON bucket_usages ( bucket_id, rollup_end_time );
|
2019-08-02 18:47:35 +01:00
|
|
|
CREATE INDEX certrecord_id_update_at ON certRecords ( id, update_at );
|
2019-07-12 18:35:20 +01:00
|
|
|
CREATE INDEX injuredsegments_attempted_index ON injuredsegments ( attempted );
|
2019-06-24 16:33:18 +01:00
|
|
|
CREATE INDEX node_last_ip ON nodes ( last_net );
|
2019-03-26 10:34:30 +00:00
|
|
|
CREATE UNIQUE INDEX serial_number ON serial_numbers ( serial_number );
|
2019-03-22 18:54:22 +00:00
|
|
|
CREATE INDEX serial_numbers_expires_at_index ON serial_numbers ( expires_at );
|
2019-03-26 10:34:30 +00:00
|
|
|
CREATE INDEX storagenode_id_interval_start_interval_seconds ON storagenode_bandwidth_rollups ( storagenode_id, interval_start, interval_seconds );
|