2019-12-17 20:07:54 +00:00
|
|
|
-- AUTOGENERATED BY storj.io/dbx
|
2018-12-05 09:35:50 +00:00
|
|
|
-- 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,
|
2020-02-11 15:33:34 +00:00
|
|
|
interval_start timestamp with time zone NOT NULL,
|
2019-03-22 18:54:22 +00:00
|
|
|
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,
|
2020-02-11 15:33:34 +00:00
|
|
|
interval_start timestamp with time zone NOT NULL,
|
2019-03-22 18:54:22 +00:00
|
|
|
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-10-17 15:04:50 +01:00
|
|
|
CREATE TABLE coinpayments_transactions (
|
|
|
|
id text NOT NULL,
|
|
|
|
user_id bytea NOT NULL,
|
|
|
|
address text NOT NULL,
|
|
|
|
amount bytea NOT NULL,
|
|
|
|
received bytea NOT NULL,
|
|
|
|
status integer NOT NULL,
|
|
|
|
key text NOT NULL,
|
2019-11-15 14:59:39 +00:00
|
|
|
timeout integer NOT NULL,
|
2019-10-17 15:04:50 +01:00
|
|
|
created_at timestamp with time zone NOT NULL,
|
|
|
|
PRIMARY KEY ( id )
|
|
|
|
);
|
2020-02-14 00:03:41 +00:00
|
|
|
CREATE TABLE consumed_serials (
|
|
|
|
storage_node_id bytea NOT NULL,
|
|
|
|
serial_number bytea NOT NULL,
|
|
|
|
expires_at timestamp with time zone NOT NULL,
|
|
|
|
PRIMARY KEY ( storage_node_id, serial_number )
|
|
|
|
);
|
2019-11-26 17:58:51 +00:00
|
|
|
CREATE TABLE coupons (
|
|
|
|
id bytea NOT NULL,
|
|
|
|
project_id bytea NOT NULL,
|
|
|
|
user_id bytea NOT NULL,
|
|
|
|
amount bigint NOT NULL,
|
|
|
|
description text NOT NULL,
|
2020-01-07 10:41:19 +00:00
|
|
|
type integer NOT NULL,
|
2019-11-26 17:58:51 +00:00
|
|
|
status integer NOT NULL,
|
|
|
|
duration bigint NOT NULL,
|
|
|
|
created_at timestamp with time zone NOT NULL,
|
2020-01-07 10:41:19 +00:00
|
|
|
PRIMARY KEY ( id )
|
2019-11-26 17:58:51 +00:00
|
|
|
);
|
|
|
|
CREATE TABLE coupon_usages (
|
|
|
|
coupon_id bytea NOT NULL,
|
|
|
|
amount bigint NOT NULL,
|
2020-01-07 10:41:19 +00:00
|
|
|
status integer NOT NULL,
|
|
|
|
period timestamp with time zone NOT NULL,
|
|
|
|
PRIMARY KEY ( coupon_id, period )
|
2019-11-26 17:58:51 +00:00
|
|
|
);
|
2020-01-24 13:38:53 +00:00
|
|
|
CREATE TABLE credits (
|
|
|
|
user_id bytea NOT NULL,
|
|
|
|
transaction_id text NOT NULL,
|
|
|
|
amount bigint NOT NULL,
|
|
|
|
created_at timestamp with time zone NOT NULL,
|
|
|
|
PRIMARY KEY ( transaction_id )
|
|
|
|
);
|
|
|
|
CREATE TABLE credits_spendings (
|
|
|
|
id bytea NOT NULL,
|
|
|
|
user_id bytea NOT NULL,
|
|
|
|
project_id bytea NOT NULL,
|
|
|
|
amount bigint NOT NULL,
|
|
|
|
status integer NOT NULL,
|
|
|
|
created_at timestamp with time zone NOT NULL,
|
|
|
|
PRIMARY KEY ( id )
|
|
|
|
);
|
2019-09-13 17:57:32 +01:00
|
|
|
CREATE TABLE graceful_exit_progress (
|
|
|
|
node_id bytea NOT NULL,
|
|
|
|
bytes_transferred bigint NOT NULL,
|
2020-01-17 00:30:39 +00:00
|
|
|
pieces_transferred bigint DEFAULT 0 NOT NULL,
|
|
|
|
pieces_failed bigint DEFAULT 0 NOT NULL,
|
2020-02-11 15:33:34 +00:00
|
|
|
updated_at timestamp with time zone NOT NULL,
|
2019-09-13 17:57:32 +01:00
|
|
|
PRIMARY KEY ( node_id )
|
|
|
|
);
|
|
|
|
CREATE TABLE graceful_exit_transfer_queue (
|
|
|
|
node_id bytea NOT NULL,
|
|
|
|
path bytea NOT NULL,
|
|
|
|
piece_num integer NOT NULL,
|
2019-11-07 16:13:05 +00:00
|
|
|
root_piece_id bytea,
|
2019-09-13 17:57:32 +01:00
|
|
|
durability_ratio double precision NOT NULL,
|
2020-02-11 15:33:34 +00:00
|
|
|
queued_at timestamp with time zone NOT NULL,
|
|
|
|
requested_at timestamp with time zone,
|
|
|
|
last_failed_at timestamp with time zone,
|
2019-09-13 17:57:32 +01:00
|
|
|
last_failed_code integer,
|
|
|
|
failed_count integer,
|
2020-02-11 15:33:34 +00:00
|
|
|
finished_at timestamp with time zone,
|
2020-01-17 00:30:39 +00:00
|
|
|
order_limit_send_count integer DEFAULT 0 NOT NULL,
|
2019-10-28 15:08:33 +00:00
|
|
|
PRIMARY KEY ( node_id, path, piece_num )
|
2019-09-13 17:57:32 +01:00
|
|
|
);
|
2018-12-21 15:11:19 +00:00
|
|
|
CREATE TABLE injuredsegments (
|
2019-07-11 18:26:07 +01:00
|
|
|
path bytea NOT NULL,
|
2019-04-16 19:14:09 +01:00
|
|
|
data bytea NOT NULL,
|
2020-02-11 15:33:34 +00:00
|
|
|
attempted timestamp with time zone,
|
2020-02-21 21:32:05 +00:00
|
|
|
num_healthy_pieces integer DEFAULT 52 NOT NULL,
|
2019-04-16 19:14:09 +01:00
|
|
|
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,
|
2020-01-17 00:30:39 +00:00
|
|
|
address text DEFAULT '' NOT NULL,
|
2019-06-24 16:33:18 +01:00
|
|
|
last_net text NOT NULL,
|
2020-03-06 22:04:23 +00:00
|
|
|
last_ip_port text,
|
2020-01-17 00:30:39 +00:00
|
|
|
protocol integer DEFAULT 0 NOT NULL,
|
|
|
|
type integer DEFAULT 0 NOT NULL,
|
2019-03-29 08:53:43 +00:00
|
|
|
email text NOT NULL,
|
|
|
|
wallet text NOT NULL,
|
2020-01-17 00:30:39 +00:00
|
|
|
free_bandwidth bigint DEFAULT -1 NOT NULL,
|
|
|
|
free_disk bigint DEFAULT -1 NOT NULL,
|
|
|
|
piece_count bigint DEFAULT 0 NOT NULL,
|
|
|
|
major bigint DEFAULT 0 NOT NULL,
|
|
|
|
minor bigint DEFAULT 0 NOT NULL,
|
|
|
|
patch bigint DEFAULT 0 NOT NULL,
|
|
|
|
hash text DEFAULT '' NOT NULL,
|
|
|
|
timestamp timestamp with time zone DEFAULT '0001-01-01 00:00:00+00' NOT NULL,
|
|
|
|
release boolean DEFAULT false NOT NULL,
|
|
|
|
latency_90 bigint DEFAULT 0 NOT NULL,
|
|
|
|
audit_success_count bigint DEFAULT 0 NOT NULL,
|
|
|
|
total_audit_count bigint DEFAULT 0 NOT NULL,
|
2018-12-14 20:17:30 +00:00
|
|
|
uptime_success_count bigint NOT NULL,
|
|
|
|
total_uptime_count bigint NOT NULL,
|
2020-01-17 00:30:39 +00:00
|
|
|
created_at timestamp with time zone DEFAULT current_timestamp NOT NULL,
|
|
|
|
updated_at timestamp with time zone DEFAULT current_timestamp NOT NULL,
|
|
|
|
last_contact_success timestamp with time zone DEFAULT 'epoch' NOT NULL,
|
|
|
|
last_contact_failure timestamp with time zone DEFAULT 'epoch' NOT NULL,
|
|
|
|
contained boolean DEFAULT false NOT NULL,
|
2019-06-18 10:14:31 +01:00
|
|
|
disqualified timestamp with time zone,
|
2020-02-11 21:32:50 +00:00
|
|
|
suspended timestamp with time zone,
|
2020-01-17 00:30:39 +00:00
|
|
|
audit_reputation_alpha double precision DEFAULT 1 NOT NULL,
|
|
|
|
audit_reputation_beta double precision DEFAULT 0 NOT NULL,
|
2020-02-11 21:32:50 +00:00
|
|
|
unknown_audit_reputation_alpha double precision DEFAULT 1 NOT NULL,
|
|
|
|
unknown_audit_reputation_beta double precision DEFAULT 0 NOT NULL,
|
2020-01-17 00:30:39 +00:00
|
|
|
uptime_reputation_alpha double precision DEFAULT 1 NOT NULL,
|
|
|
|
uptime_reputation_beta double precision DEFAULT 0 NOT NULL,
|
2020-02-11 15:33:34 +00:00
|
|
|
exit_initiated_at timestamp with time zone,
|
|
|
|
exit_loop_completed_at timestamp with time zone,
|
|
|
|
exit_finished_at timestamp with time zone,
|
2020-01-17 00:30:39 +00:00
|
|
|
exit_success boolean DEFAULT false NOT NULL,
|
2018-12-14 20:17:30 +00:00
|
|
|
PRIMARY KEY ( id )
|
|
|
|
);
|
2019-12-27 22:03:03 +00:00
|
|
|
CREATE TABLE nodes_offline_times (
|
|
|
|
node_id bytea NOT NULL,
|
|
|
|
tracked_at timestamp with time zone NOT NULL,
|
|
|
|
seconds integer NOT NULL,
|
|
|
|
PRIMARY KEY ( node_id, tracked_at )
|
|
|
|
);
|
2019-05-22 22:41:55 +01:00
|
|
|
CREATE TABLE offers (
|
|
|
|
id serial NOT NULL,
|
|
|
|
name text NOT NULL,
|
|
|
|
description text NOT NULL,
|
2020-01-17 00:30:39 +00:00
|
|
|
award_credit_in_cents integer DEFAULT 0 NOT NULL,
|
|
|
|
invitee_credit_in_cents integer DEFAULT 0 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 with time zone NOT NULL,
|
2019-05-22 22:41:55 +01:00
|
|
|
created_at timestamp with time zone 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-08-26 17:49:42 +01:00
|
|
|
CREATE TABLE peer_identities (
|
|
|
|
node_id bytea NOT NULL,
|
|
|
|
leaf_serial_number bytea NOT NULL,
|
|
|
|
chain bytea NOT NULL,
|
|
|
|
updated_at timestamp with time zone NOT NULL,
|
|
|
|
PRIMARY KEY ( node_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,
|
2019-07-18 19:08:15 +01:00
|
|
|
path bytea NOT NULL,
|
2019-05-16 15:11:15 +01:00
|
|
|
PRIMARY KEY ( node_id )
|
|
|
|
);
|
2020-02-14 00:03:41 +00:00
|
|
|
CREATE TABLE pending_serial_queue (
|
|
|
|
storage_node_id bytea NOT NULL,
|
|
|
|
bucket_id bytea NOT NULL,
|
|
|
|
serial_number bytea NOT NULL,
|
|
|
|
action integer NOT NULL,
|
|
|
|
settled bigint NOT NULL,
|
|
|
|
expires_at timestamp with time zone NOT NULL,
|
|
|
|
PRIMARY KEY ( storage_node_id, bucket_id, serial_number )
|
|
|
|
);
|
2019-01-16 20:23:28 +00:00
|
|
|
CREATE TABLE projects (
|
|
|
|
id bytea NOT NULL,
|
|
|
|
name text NOT NULL,
|
|
|
|
description text NOT NULL,
|
2020-01-17 00:30:39 +00:00
|
|
|
usage_limit bigint DEFAULT 0 NOT NULL,
|
2020-01-17 15:01:36 +00:00
|
|
|
rate_limit integer,
|
2019-07-12 18:59:19 +01:00
|
|
|
partner_id bytea,
|
2019-08-07 13:28:13 +01:00
|
|
|
owner_id bytea NOT NULL,
|
2019-01-16 20:23:28 +00:00
|
|
|
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 )
|
|
|
|
);
|
2020-01-15 21:45:17 +00:00
|
|
|
CREATE TABLE reported_serials (
|
2020-01-16 18:02:15 +00:00
|
|
|
expires_at timestamp with time zone NOT NULL,
|
2020-01-15 21:45:17 +00:00
|
|
|
storage_node_id bytea NOT NULL,
|
|
|
|
bucket_id bytea NOT NULL,
|
|
|
|
action integer NOT NULL,
|
|
|
|
serial_number bytea NOT NULL,
|
|
|
|
settled bigint NOT NULL,
|
2020-01-16 18:02:15 +00:00
|
|
|
observed_at timestamp with time zone NOT NULL,
|
2020-01-15 21:45:17 +00:00
|
|
|
PRIMARY KEY ( expires_at, storage_node_id, bucket_id, action, serial_number )
|
|
|
|
);
|
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,
|
2020-02-11 15:33:34 +00:00
|
|
|
expires_at timestamp with time zone 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,
|
2020-02-11 15:33:34 +00:00
|
|
|
interval_start timestamp with time zone NOT NULL,
|
2019-03-22 18:54:22 +00:00
|
|
|
interval_seconds integer NOT NULL,
|
|
|
|
action integer NOT NULL,
|
2020-01-15 07:25:26 +00:00
|
|
|
allocated bigint DEFAULT 0,
|
2019-03-22 18:54:22 +00:00
|
|
|
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
|
|
|
);
|
2020-02-18 19:52:18 +00:00
|
|
|
CREATE TABLE storagenode_payments (
|
|
|
|
id bigserial NOT NULL,
|
|
|
|
created_at timestamp with time zone NOT NULL,
|
|
|
|
node_id bytea NOT NULL,
|
|
|
|
period text,
|
|
|
|
amount bigint NOT NULL,
|
|
|
|
receipt text,
|
|
|
|
notes text,
|
|
|
|
PRIMARY KEY ( id )
|
|
|
|
);
|
|
|
|
CREATE TABLE storagenode_paystubs (
|
|
|
|
period text NOT NULL,
|
|
|
|
node_id bytea NOT NULL,
|
|
|
|
created_at timestamp with time zone NOT NULL,
|
|
|
|
codes text NOT NULL,
|
|
|
|
usage_at_rest double precision NOT NULL,
|
|
|
|
usage_get bigint NOT NULL,
|
|
|
|
usage_put bigint NOT NULL,
|
|
|
|
usage_get_repair bigint NOT NULL,
|
|
|
|
usage_put_repair bigint NOT NULL,
|
|
|
|
usage_get_audit bigint NOT NULL,
|
|
|
|
comp_at_rest bigint NOT NULL,
|
|
|
|
comp_get bigint NOT NULL,
|
|
|
|
comp_put bigint NOT NULL,
|
|
|
|
comp_get_repair bigint NOT NULL,
|
|
|
|
comp_put_repair bigint NOT NULL,
|
|
|
|
comp_get_audit bigint NOT NULL,
|
|
|
|
surge_percent bigint NOT NULL,
|
|
|
|
held bigint NOT NULL,
|
|
|
|
owed bigint NOT NULL,
|
|
|
|
disposed bigint NOT NULL,
|
|
|
|
paid bigint NOT NULL,
|
|
|
|
PRIMARY KEY ( period, node_id )
|
|
|
|
);
|
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-10-10 18:12:23 +01:00
|
|
|
CREATE TABLE stripe_customers (
|
|
|
|
user_id bytea NOT NULL,
|
|
|
|
customer_id text NOT NULL,
|
|
|
|
created_at timestamp with time zone NOT NULL,
|
|
|
|
PRIMARY KEY ( user_id ),
|
|
|
|
UNIQUE ( customer_id )
|
|
|
|
);
|
2019-11-05 13:16:02 +00:00
|
|
|
CREATE TABLE stripecoinpayments_invoice_project_records (
|
|
|
|
id bytea NOT NULL,
|
|
|
|
project_id bytea NOT NULL,
|
|
|
|
storage double precision NOT NULL,
|
|
|
|
egress bigint NOT NULL,
|
|
|
|
objects bigint NOT NULL,
|
|
|
|
period_start timestamp with time zone NOT NULL,
|
|
|
|
period_end timestamp with time zone NOT NULL,
|
|
|
|
state integer NOT NULL,
|
|
|
|
created_at timestamp with time zone NOT NULL,
|
|
|
|
PRIMARY KEY ( id ),
|
|
|
|
UNIQUE ( project_id, period_start, period_end )
|
|
|
|
);
|
2019-11-15 14:59:39 +00:00
|
|
|
CREATE TABLE stripecoinpayments_tx_conversion_rates (
|
|
|
|
tx_id text NOT NULL,
|
|
|
|
rate bytea NOT NULL,
|
|
|
|
created_at timestamp with time zone NOT NULL,
|
|
|
|
PRIMARY KEY ( tx_id )
|
|
|
|
);
|
2019-01-16 20:23:28 +00:00
|
|
|
CREATE TABLE users (
|
|
|
|
id bytea NOT NULL,
|
2019-06-06 17:07:14 +01:00
|
|
|
email text NOT NULL,
|
2019-09-10 15:00:33 +01:00
|
|
|
normalized_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 bytea NOT NULL,
|
2019-02-11 10:33:56 +00:00
|
|
|
status integer NOT NULL,
|
2019-07-12 18:59:19 +01:00
|
|
|
partner_id bytea,
|
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
|
|
|
);
|
2019-06-05 17:06:14 +01:00
|
|
|
CREATE TABLE value_attributions (
|
2019-06-13 13:28:55 +01:00
|
|
|
project_id bytea NOT NULL,
|
|
|
|
bucket_name bytea NOT NULL,
|
2019-06-05 17:06:14 +01:00
|
|
|
partner_id bytea NOT NULL,
|
2020-02-11 15:33:34 +00:00
|
|
|
last_updated timestamp with time zone 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 bytea NOT NULL,
|
|
|
|
project_id bytea NOT NULL REFERENCES projects( id ) ON DELETE CASCADE,
|
2019-05-24 17:51:27 +01:00
|
|
|
head bytea NOT NULL,
|
2019-01-16 20:23:28 +00:00
|
|
|
name text NOT NULL,
|
2019-05-24 17:51:27 +01:00
|
|
|
secret bytea NOT NULL,
|
2019-07-12 18:59:19 +01:00
|
|
|
partner_id bytea,
|
2019-01-16 20:23:28 +00:00
|
|
|
created_at timestamp with time zone 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 bytea NOT NULL,
|
|
|
|
project_id bytea NOT NULL REFERENCES projects( id ),
|
|
|
|
name bytea NOT NULL,
|
2019-07-12 18:59:19 +01:00
|
|
|
partner_id bytea,
|
2019-07-01 21:45:21 +01:00
|
|
|
path_cipher integer NOT NULL,
|
2019-07-03 23:03:56 +01:00
|
|
|
created_at timestamp with time zone NOT NULL,
|
2019-07-01 21:45:21 +01:00
|
|
|
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 bytea NOT NULL REFERENCES projects( id ) ON DELETE CASCADE,
|
|
|
|
invoice_id bytea NOT NULL,
|
|
|
|
start_date timestamp with time zone NOT NULL,
|
|
|
|
end_date timestamp with time zone NOT NULL,
|
|
|
|
created_at timestamp with time zone 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 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-10-29 16:04:34 +00:00
|
|
|
CREATE TABLE stripecoinpayments_apply_balance_intents (
|
|
|
|
tx_id text NOT NULL REFERENCES coinpayments_transactions( id ) ON DELETE CASCADE,
|
|
|
|
state integer NOT NULL,
|
|
|
|
created_at timestamp with time zone NOT NULL,
|
|
|
|
PRIMARY KEY ( tx_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-06-13 14:52:33 +01:00
|
|
|
CREATE TABLE user_credits (
|
|
|
|
id serial NOT NULL,
|
2019-08-01 18:46:33 +01:00
|
|
|
user_id bytea 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 bytea 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 with time zone NOT NULL,
|
|
|
|
created_at timestamp with time zone NOT NULL,
|
2019-12-11 23:49:57 +00:00
|
|
|
PRIMARY KEY ( id ),
|
|
|
|
UNIQUE ( id, offer_id )
|
2019-06-13 14:52:33 +01:00
|
|
|
);
|
2020-02-18 19:52:18 +00:00
|
|
|
CREATE INDEX accounting_rollups_start_time_index ON accounting_rollups ( start_time );
|
2020-02-14 00:03:41 +00:00
|
|
|
CREATE INDEX consumed_serials_expires_at_index ON consumed_serials ( expires_at );
|
2019-07-12 18:35:20 +01:00
|
|
|
CREATE INDEX injuredsegments_attempted_index ON injuredsegments ( attempted );
|
2020-02-21 21:32:05 +00:00
|
|
|
CREATE INDEX injuredsegments_num_healthy_pieces_index ON injuredsegments ( num_healthy_pieces );
|
2019-06-24 16:33:18 +01:00
|
|
|
CREATE INDEX node_last_ip ON nodes ( last_net );
|
2019-12-27 22:03:03 +00:00
|
|
|
CREATE INDEX nodes_offline_times_node_id_index ON nodes_offline_times ( node_id );
|
2020-01-17 00:30:39 +00:00
|
|
|
CREATE UNIQUE INDEX serial_number_index 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 );
|
2020-02-18 19:52:18 +00:00
|
|
|
CREATE INDEX storagenode_payments_node_id_period_index ON storagenode_payments ( node_id, period );
|
|
|
|
CREATE INDEX storagenode_paystubs_node_id_index ON storagenode_paystubs ( node_id );
|
2019-12-11 23:49:57 +00:00
|
|
|
CREATE UNIQUE INDEX credits_earned_user_id_offer_id ON user_credits ( id, offer_id );
|