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 bigserial NOT NULL,
|
2019-01-16 19:30:33 +00:00
|
|
|
node_id bytea NOT NULL,
|
2018-12-18 17:18:42 +00:00
|
|
|
start_time timestamp with time zone NOT NULL,
|
2019-01-16 19:30:33 +00:00
|
|
|
put_total bigint NOT NULL,
|
|
|
|
get_total bigint NOT NULL,
|
|
|
|
get_audit_total bigint NOT NULL,
|
|
|
|
get_repair_total bigint NOT NULL,
|
|
|
|
put_repair_total bigint NOT NULL,
|
|
|
|
at_rest_total double precision NOT NULL,
|
2018-12-18 17:18:42 +00:00
|
|
|
PRIMARY KEY ( id )
|
|
|
|
);
|
|
|
|
CREATE TABLE accounting_timestamps (
|
|
|
|
name text NOT NULL,
|
|
|
|
value timestamp with time zone 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 bytea NOT NULL,
|
|
|
|
project_id bytea 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 bigint NOT NULL,
|
|
|
|
allocated bigint NOT NULL,
|
|
|
|
settled bigint 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 bytea NOT NULL,
|
|
|
|
project_id bytea NOT NULL,
|
2019-03-22 18:54:22 +00:00
|
|
|
interval_start timestamp NOT NULL,
|
|
|
|
inline bigint NOT NULL,
|
|
|
|
remote bigint 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 bigint 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 bytea NOT NULL,
|
|
|
|
bucket_id bytea NOT NULL,
|
|
|
|
rollup_end_time timestamp with time zone NOT NULL,
|
|
|
|
remote_stored_data bigint NOT NULL,
|
|
|
|
inline_stored_data bigint NOT NULL,
|
|
|
|
remote_segments integer NOT NULL,
|
|
|
|
inline_segments integer NOT NULL,
|
|
|
|
objects integer NOT NULL,
|
|
|
|
metadata_size bigint NOT NULL,
|
|
|
|
repair_egress bigint NOT NULL,
|
|
|
|
get_egress bigint NOT NULL,
|
|
|
|
audit_egress bigint NOT NULL,
|
2019-03-26 10:34:30 +00:00
|
|
|
PRIMARY KEY ( id )
|
2019-03-06 15:54:48 +00:00
|
|
|
);
|
2018-12-07 09:59:31 +00:00
|
|
|
CREATE TABLE bwagreements (
|
2019-01-09 15:02:03 +00:00
|
|
|
serialnum text NOT NULL,
|
2019-02-01 18:50:12 +00:00
|
|
|
storage_node_id bytea NOT NULL,
|
|
|
|
uplink_id bytea NOT NULL,
|
2019-01-28 21:16:21 +00:00
|
|
|
action bigint NOT NULL,
|
|
|
|
total bigint NOT NULL,
|
2018-12-07 09:59:31 +00:00
|
|
|
created_at timestamp with time zone NOT NULL,
|
2019-01-10 18:30:55 +00:00
|
|
|
expires_at timestamp with time zone NOT NULL,
|
2019-01-28 21:16:21 +00:00
|
|
|
PRIMARY KEY ( serialnum )
|
2018-12-05 09:35:50 +00:00
|
|
|
);
|
2019-02-07 19:22:49 +00:00
|
|
|
CREATE TABLE certRecords (
|
|
|
|
publickey bytea NOT NULL,
|
|
|
|
id bytea NOT NULL,
|
|
|
|
update_at timestamp with time zone NOT NULL,
|
|
|
|
PRIMARY KEY ( id )
|
|
|
|
);
|
2018-12-21 15:11:19 +00:00
|
|
|
CREATE TABLE injuredsegments (
|
2019-04-16 19:14:09 +01:00
|
|
|
path text NOT NULL,
|
|
|
|
data bytea 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 bytea NOT NULL,
|
|
|
|
segmentdetail bytea NOT NULL,
|
|
|
|
pieces_lost_count bigint NOT NULL,
|
|
|
|
seg_damaged_unix_sec bigint NOT NULL,
|
|
|
|
repair_attempt_count bigint NOT NULL,
|
|
|
|
PRIMARY KEY ( segmentpath )
|
|
|
|
);
|
2018-12-14 20:17:30 +00:00
|
|
|
CREATE TABLE nodes (
|
|
|
|
id bytea NOT NULL,
|
2019-03-29 08:53:43 +00:00
|
|
|
address text NOT NULL,
|
|
|
|
protocol integer NOT NULL,
|
|
|
|
type integer NOT NULL,
|
|
|
|
email text NOT NULL,
|
|
|
|
wallet text NOT NULL,
|
|
|
|
free_bandwidth bigint NOT NULL,
|
|
|
|
free_disk bigint NOT NULL,
|
2019-04-10 07:04:24 +01:00
|
|
|
major bigint NOT NULL,
|
|
|
|
minor bigint NOT NULL,
|
|
|
|
patch bigint NOT NULL,
|
|
|
|
hash text NOT NULL,
|
|
|
|
timestamp timestamp with time zone NOT NULL,
|
|
|
|
release boolean NOT NULL,
|
2019-03-29 08:53:43 +00:00
|
|
|
latency_90 bigint NOT NULL,
|
2018-12-14 20:17:30 +00:00
|
|
|
audit_success_count bigint NOT NULL,
|
|
|
|
total_audit_count bigint NOT NULL,
|
|
|
|
audit_success_ratio double precision NOT NULL,
|
|
|
|
uptime_success_count bigint NOT NULL,
|
|
|
|
total_uptime_count bigint NOT NULL,
|
|
|
|
uptime_ratio double precision NOT NULL,
|
|
|
|
created_at timestamp with time zone NOT NULL,
|
|
|
|
updated_at timestamp with time zone NOT NULL,
|
2019-03-29 08:53:43 +00:00
|
|
|
last_contact_success timestamp with time zone NOT NULL,
|
|
|
|
last_contact_failure timestamp with time zone NOT NULL,
|
2019-05-16 15:11:15 +01:00
|
|
|
contained boolean NOT NULL,
|
2018-12-14 20:17:30 +00:00
|
|
|
PRIMARY KEY ( id )
|
|
|
|
);
|
2019-05-16 15:11:15 +01:00
|
|
|
CREATE TABLE pending_audits (
|
|
|
|
node_id bytea NOT NULL,
|
|
|
|
piece_id bytea NOT NULL,
|
|
|
|
stripe_index bigint NOT NULL,
|
|
|
|
share_size bigint NOT NULL,
|
|
|
|
expected_share_hash bytea NOT NULL,
|
|
|
|
reverify_count bigint NOT NULL,
|
|
|
|
PRIMARY KEY ( node_id )
|
|
|
|
);
|
2019-01-16 20:23:28 +00:00
|
|
|
CREATE TABLE projects (
|
|
|
|
id bytea NOT NULL,
|
|
|
|
name text NOT NULL,
|
|
|
|
description text NOT NULL,
|
|
|
|
created_at timestamp with time zone NOT NULL,
|
|
|
|
PRIMARY KEY ( id )
|
|
|
|
);
|
2019-03-19 17:55:43 +00:00
|
|
|
CREATE TABLE registration_tokens (
|
|
|
|
secret bytea NOT NULL,
|
|
|
|
owner_id bytea,
|
|
|
|
project_limit integer NOT NULL,
|
|
|
|
created_at timestamp with time zone NOT NULL,
|
|
|
|
PRIMARY KEY ( secret ),
|
|
|
|
UNIQUE ( owner_id )
|
|
|
|
);
|
2019-05-13 16:53:52 +01:00
|
|
|
CREATE TABLE reset_password_tokens (
|
|
|
|
secret bytea NOT NULL,
|
|
|
|
owner_id bytea NOT NULL,
|
|
|
|
created_at timestamp with time zone NOT NULL,
|
|
|
|
PRIMARY KEY ( secret ),
|
|
|
|
UNIQUE ( owner_id )
|
|
|
|
);
|
2019-03-22 18:54:22 +00:00
|
|
|
CREATE TABLE serial_numbers (
|
|
|
|
id serial NOT NULL,
|
|
|
|
serial_number bytea NOT NULL,
|
|
|
|
bucket_id bytea 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 bytea NOT NULL,
|
|
|
|
interval_start timestamp NOT NULL,
|
|
|
|
interval_seconds integer NOT NULL,
|
|
|
|
action integer NOT NULL,
|
|
|
|
allocated bigint NOT NULL,
|
|
|
|
settled bigint 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 bigserial NOT NULL,
|
|
|
|
node_id bytea NOT NULL,
|
|
|
|
interval_end_time timestamp with time zone NOT NULL,
|
|
|
|
data_total double precision 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 bytea NOT NULL,
|
2019-03-27 12:33:32 +00:00
|
|
|
full_name text NOT NULL,
|
|
|
|
short_name text,
|
2019-02-11 10:33:56 +00:00
|
|
|
email text NOT NULL,
|
2019-01-16 20:23:28 +00:00
|
|
|
password_hash bytea NOT NULL,
|
2019-02-11 10:33:56 +00:00
|
|
|
status integer NOT NULL,
|
2019-01-16 20:23:28 +00:00
|
|
|
created_at timestamp with time zone NOT NULL,
|
2019-02-11 10:33:56 +00:00
|
|
|
PRIMARY KEY ( id )
|
2019-01-16 20:23:28 +00:00
|
|
|
);
|
|
|
|
CREATE TABLE api_keys (
|
|
|
|
id bytea NOT NULL,
|
|
|
|
project_id bytea NOT NULL REFERENCES projects( id ) ON DELETE CASCADE,
|
|
|
|
key bytea NOT NULL,
|
|
|
|
name text NOT NULL,
|
|
|
|
created_at timestamp with time zone NOT NULL,
|
|
|
|
PRIMARY KEY ( id ),
|
|
|
|
UNIQUE ( key ),
|
|
|
|
UNIQUE ( name, project_id )
|
|
|
|
);
|
|
|
|
CREATE TABLE project_members (
|
|
|
|
member_id bytea NOT NULL REFERENCES users( id ) ON DELETE CASCADE,
|
|
|
|
project_id bytea NOT NULL REFERENCES projects( id ) ON DELETE CASCADE,
|
|
|
|
created_at timestamp with time zone 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 bytea 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-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 );
|
|
|
|
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 );
|