2018-12-05 09:35:50 +00:00
|
|
|
// dbx.v1 golang satellitedb.dbx .
|
|
|
|
|
2019-06-05 17:06:14 +01:00
|
|
|
//--- Value Attribution ---//
|
|
|
|
model value_attribution (
|
2019-06-13 13:28:55 +01:00
|
|
|
key project_id bucket_name
|
2019-06-05 17:06:14 +01:00
|
|
|
|
2019-06-13 13:28:55 +01:00
|
|
|
field project_id blob
|
|
|
|
field bucket_name blob
|
2019-06-05 17:06:14 +01:00
|
|
|
field partner_id blob
|
2019-06-18 14:06:33 +01:00
|
|
|
field last_updated utimestamp ( autoinsert, autoupdate )
|
|
|
|
)
|
|
|
|
|
|
|
|
create value_attribution ()
|
2019-06-19 13:02:37 +01:00
|
|
|
delete value_attribution (
|
|
|
|
where value_attribution.project_id = ?
|
|
|
|
where value_attribution.bucket_name = ?
|
|
|
|
)
|
2019-06-18 14:06:33 +01:00
|
|
|
|
|
|
|
read one (
|
|
|
|
select value_attribution
|
2019-06-19 13:02:37 +01:00
|
|
|
where value_attribution.project_id = ?
|
2019-06-19 13:50:50 +01:00
|
|
|
where value_attribution.bucket_name = ?
|
2019-06-05 17:06:14 +01:00
|
|
|
)
|
|
|
|
|
2019-05-16 15:11:15 +01:00
|
|
|
//--- containment ---//
|
|
|
|
model pending_audits (
|
|
|
|
key node_id
|
|
|
|
|
|
|
|
field node_id blob
|
|
|
|
field piece_id blob
|
|
|
|
field stripe_index int64
|
|
|
|
field share_size int64
|
|
|
|
field expected_share_hash blob
|
|
|
|
field reverify_count int64 ( updatable )
|
|
|
|
)
|
|
|
|
|
|
|
|
create pending_audits ( )
|
|
|
|
update pending_audits ( where pending_audits.node_id = ? )
|
|
|
|
delete pending_audits ( where pending_audits.node_id = ? )
|
|
|
|
read one (
|
|
|
|
select pending_audits
|
|
|
|
where pending_audits.node_id = ?
|
|
|
|
)
|
|
|
|
|
2019-03-15 20:21:52 +00:00
|
|
|
//--- irreparableDB ---//
|
2018-12-14 14:27:21 +00:00
|
|
|
|
2018-12-10 19:08:45 +00:00
|
|
|
model irreparabledb (
|
|
|
|
key segmentpath
|
|
|
|
|
2018-12-27 21:21:50 +00:00
|
|
|
field segmentpath blob
|
|
|
|
field segmentdetail blob ( updatable )
|
|
|
|
field pieces_lost_count int64 ( updatable )
|
|
|
|
field seg_damaged_unix_sec int64 ( updatable )
|
|
|
|
field repair_attempt_count int64 ( updatable )
|
2018-12-10 19:08:45 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
create irreparabledb ( )
|
|
|
|
update irreparabledb ( where irreparabledb.segmentpath = ? )
|
|
|
|
delete irreparabledb ( where irreparabledb.segmentpath = ? )
|
2018-12-27 21:21:50 +00:00
|
|
|
|
2018-12-10 19:08:45 +00:00
|
|
|
read one (
|
2018-12-27 21:21:50 +00:00
|
|
|
select irreparabledb
|
|
|
|
where irreparabledb.segmentpath = ?
|
2018-12-14 14:27:21 +00:00
|
|
|
)
|
|
|
|
|
2019-04-10 07:04:24 +01:00
|
|
|
read limitoffset (
|
|
|
|
select irreparabledb
|
|
|
|
orderby asc irreparabledb.segmentpath
|
2019-03-15 20:21:52 +00:00
|
|
|
)
|
|
|
|
|
2018-12-14 14:27:21 +00:00
|
|
|
//--- accounting ---//
|
|
|
|
|
2018-12-18 17:18:42 +00:00
|
|
|
// accounting_timestamps just allows us to save the last time/thing that happened
|
|
|
|
model accounting_timestamps (
|
2018-12-27 21:21:50 +00:00
|
|
|
key name
|
2018-12-14 14:27:21 +00:00
|
|
|
|
2018-12-27 21:21:50 +00:00
|
|
|
field name text
|
|
|
|
field value timestamp ( updatable )
|
2018-12-14 14:27:21 +00:00
|
|
|
)
|
2018-12-27 21:21:50 +00:00
|
|
|
|
2018-12-18 17:18:42 +00:00
|
|
|
create accounting_timestamps ( )
|
|
|
|
update accounting_timestamps ( where accounting_timestamps.name = ? )
|
2018-12-27 21:21:50 +00:00
|
|
|
|
2018-12-14 14:27:21 +00:00
|
|
|
read scalar (
|
2018-12-27 21:21:50 +00:00
|
|
|
select accounting_timestamps.value
|
|
|
|
where accounting_timestamps.name = ?
|
2018-12-14 14:27:21 +00:00
|
|
|
)
|
|
|
|
|
2018-12-18 17:18:42 +00:00
|
|
|
model accounting_rollup (
|
2018-12-27 21:21:50 +00:00
|
|
|
key id
|
|
|
|
|
2019-01-16 19:30:33 +00:00
|
|
|
field id serial64
|
|
|
|
field node_id blob
|
|
|
|
field start_time timestamp
|
|
|
|
field put_total int64
|
|
|
|
field get_total int64
|
|
|
|
field get_audit_total int64
|
2019-04-10 07:04:24 +01:00
|
|
|
field get_repair_total int64
|
2019-01-16 19:30:33 +00:00
|
|
|
field put_repair_total int64
|
|
|
|
field at_rest_total float64
|
2018-12-14 14:27:21 +00:00
|
|
|
)
|
|
|
|
|
2018-12-18 17:18:42 +00:00
|
|
|
create accounting_rollup ( )
|
|
|
|
delete accounting_rollup ( where accounting_rollup.id = ? )
|
2018-12-27 21:21:50 +00:00
|
|
|
|
2018-12-14 14:27:21 +00:00
|
|
|
read one (
|
2018-12-27 21:21:50 +00:00
|
|
|
select accounting_rollup
|
|
|
|
where accounting_rollup.id = ?
|
2018-12-14 14:27:21 +00:00
|
|
|
)
|
2018-12-27 21:21:50 +00:00
|
|
|
|
2018-12-14 14:27:21 +00:00
|
|
|
read all (
|
2018-12-27 21:21:50 +00:00
|
|
|
select accounting_rollup
|
2019-01-16 19:30:33 +00:00
|
|
|
where accounting_rollup.start_time >= ?
|
2018-12-14 14:27:21 +00:00
|
|
|
)
|
|
|
|
|
2018-12-18 17:18:42 +00:00
|
|
|
//--- statdb ---//
|
|
|
|
|
2018-12-14 20:17:30 +00:00
|
|
|
model node (
|
|
|
|
key id
|
|
|
|
|
2019-06-18 10:14:31 +01:00
|
|
|
index (
|
2019-05-22 21:06:27 +01:00
|
|
|
name node_last_ip
|
2019-06-24 16:33:18 +01:00
|
|
|
fields last_net
|
2019-05-22 21:06:27 +01:00
|
|
|
)
|
|
|
|
|
2019-03-29 08:53:43 +00:00
|
|
|
field id blob
|
|
|
|
field address text ( updatable ) // TODO: use compressed format
|
2019-06-24 16:33:18 +01:00
|
|
|
field last_net text ( updatable )
|
2019-03-29 08:53:43 +00:00
|
|
|
field protocol int ( updatable )
|
|
|
|
field type int ( updatable )
|
|
|
|
field email text ( updatable )
|
|
|
|
field wallet text ( updatable ) // TODO: use compressed format
|
|
|
|
field free_bandwidth int64 ( updatable )
|
|
|
|
field free_disk int64 ( updatable )
|
|
|
|
|
2019-04-10 07:04:24 +01:00
|
|
|
field major int64 ( updatable )
|
|
|
|
field minor int64 ( updatable )
|
|
|
|
field patch int64 ( updatable )
|
|
|
|
field hash text ( updatable )
|
|
|
|
field timestamp timestamp ( updatable )
|
|
|
|
field release bool ( updatable )
|
|
|
|
|
2019-03-29 08:53:43 +00:00
|
|
|
field latency_90 int64 ( updatable )
|
|
|
|
field audit_success_count int64 ( updatable )
|
|
|
|
field total_audit_count int64 ( updatable )
|
2018-12-27 21:21:50 +00:00
|
|
|
field uptime_success_count int64 ( updatable )
|
|
|
|
field total_uptime_count int64 ( updatable )
|
2018-12-14 20:17:30 +00:00
|
|
|
|
2019-03-29 08:53:43 +00:00
|
|
|
field created_at timestamp ( autoinsert )
|
|
|
|
field updated_at timestamp ( autoinsert, autoupdate )
|
2019-04-01 19:42:06 +01:00
|
|
|
field last_contact_success timestamp ( updatable )
|
|
|
|
field last_contact_failure timestamp ( updatable )
|
2019-05-16 15:11:15 +01:00
|
|
|
|
|
|
|
field contained bool ( updatable )
|
2019-06-18 10:14:31 +01:00
|
|
|
field disqualified timestamp ( updatable, nullable )
|
2019-06-18 14:45:02 +01:00
|
|
|
|
|
|
|
field audit_reputation_alpha float64 ( updatable )
|
|
|
|
field audit_reputation_beta float64 ( updatable )
|
|
|
|
field uptime_reputation_alpha float64 ( updatable )
|
|
|
|
field uptime_reputation_beta float64 ( updatable )
|
2018-12-14 20:17:30 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
create node ( )
|
|
|
|
update node ( where node.id = ? )
|
|
|
|
delete node ( where node.id = ? )
|
2018-12-27 21:21:50 +00:00
|
|
|
|
2019-03-19 00:15:27 +00:00
|
|
|
// "Get" query; fails if node not found
|
2018-12-14 20:17:30 +00:00
|
|
|
read one (
|
2018-12-27 21:21:50 +00:00
|
|
|
select node
|
|
|
|
where node.id = ?
|
2018-12-14 20:17:30 +00:00
|
|
|
)
|
2018-12-17 20:14:16 +00:00
|
|
|
|
2019-01-17 18:34:13 +00:00
|
|
|
read all (
|
|
|
|
select node.id
|
|
|
|
)
|
|
|
|
|
2018-12-17 20:14:16 +00:00
|
|
|
read limitoffset (
|
2019-03-29 08:53:43 +00:00
|
|
|
select node
|
|
|
|
where node.id >= ?
|
|
|
|
orderby asc node.id
|
2018-12-17 20:14:16 +00:00
|
|
|
)
|
|
|
|
|
2018-12-21 15:11:19 +00:00
|
|
|
//--- repairqueue ---//
|
|
|
|
|
|
|
|
model injuredsegment (
|
2019-04-16 19:14:09 +01:00
|
|
|
key path
|
2018-12-27 21:21:50 +00:00
|
|
|
|
2019-04-16 19:14:09 +01:00
|
|
|
field path text
|
|
|
|
field data blob
|
|
|
|
field attempted utimestamp (updatable, nullable)
|
2018-12-21 15:11:19 +00:00
|
|
|
)
|
2018-12-27 21:21:50 +00:00
|
|
|
|
2019-01-16 20:23:28 +00:00
|
|
|
//--- satellite console ---//
|
|
|
|
|
|
|
|
model user (
|
|
|
|
key id
|
|
|
|
|
2019-01-30 15:04:40 +00:00
|
|
|
field id blob
|
2019-06-06 17:07:14 +01:00
|
|
|
field email text ( updatable )
|
2019-03-27 12:33:32 +00:00
|
|
|
field full_name text ( updatable )
|
|
|
|
field short_name text ( updatable, nullable )
|
2019-01-30 15:04:40 +00:00
|
|
|
field password_hash blob ( updatable )
|
|
|
|
|
2019-02-11 10:33:56 +00:00
|
|
|
field status int ( updatable, autoinsert )
|
|
|
|
|
2019-01-30 15:04:40 +00:00
|
|
|
field created_at timestamp ( autoinsert )
|
2019-01-16 20:23:28 +00:00
|
|
|
)
|
2019-06-06 17:07:14 +01:00
|
|
|
|
|
|
|
create user ( )
|
|
|
|
update user ( where user.id = ? )
|
|
|
|
delete user ( where user.id = ? )
|
|
|
|
|
2019-01-16 20:23:28 +00:00
|
|
|
read one (
|
|
|
|
select user
|
|
|
|
where user.email = ?
|
2019-02-11 10:33:56 +00:00
|
|
|
where user.status != 0
|
2019-01-16 20:23:28 +00:00
|
|
|
)
|
|
|
|
read one (
|
|
|
|
select user
|
|
|
|
where user.id = ?
|
|
|
|
)
|
|
|
|
|
2019-06-06 17:07:14 +01:00
|
|
|
// add payment method id to indentify if it has been set up
|
|
|
|
model user_payment (
|
|
|
|
key user_id
|
|
|
|
unique customer_id
|
|
|
|
|
|
|
|
field user_id user.id cascade
|
|
|
|
field customer_id blob
|
|
|
|
|
|
|
|
field created_at timestamp ( autoinsert )
|
|
|
|
)
|
|
|
|
|
|
|
|
create user_payment ( )
|
|
|
|
|
|
|
|
read one (
|
|
|
|
select user_payment
|
|
|
|
where user_payment.user_id = ?
|
|
|
|
)
|
2019-01-16 20:23:28 +00:00
|
|
|
|
|
|
|
model project (
|
|
|
|
key id
|
|
|
|
|
|
|
|
field id blob
|
|
|
|
|
|
|
|
field name text
|
|
|
|
field description text ( updatable )
|
2019-05-28 16:36:52 +01:00
|
|
|
field usage_limit int64 ( updatable )
|
2019-01-16 20:23:28 +00:00
|
|
|
|
|
|
|
field created_at timestamp ( autoinsert )
|
|
|
|
)
|
2019-06-06 17:07:14 +01:00
|
|
|
|
|
|
|
create project ( )
|
|
|
|
update project ( where project.id = ? )
|
|
|
|
delete project ( where project.id = ? )
|
|
|
|
|
2019-01-16 20:23:28 +00:00
|
|
|
read one (
|
|
|
|
select project
|
|
|
|
where project.id = ?
|
|
|
|
)
|
2019-06-06 17:07:14 +01:00
|
|
|
read all (
|
|
|
|
select project
|
|
|
|
)
|
|
|
|
read all (
|
|
|
|
select project
|
|
|
|
where project.created_at < ?
|
|
|
|
orderby asc project.created_at
|
|
|
|
)
|
2019-01-16 20:23:28 +00:00
|
|
|
read all (
|
|
|
|
select project
|
|
|
|
join project.id = project_member.project_id
|
|
|
|
where project_member.member_id = ?
|
|
|
|
orderby asc project.name
|
|
|
|
)
|
|
|
|
|
2019-06-06 17:07:14 +01:00
|
|
|
// add is default, make composite key
|
|
|
|
model project_payment (
|
|
|
|
key project_id
|
|
|
|
|
|
|
|
field project_id project.id cascade
|
|
|
|
field payer_id user_payment.user_id cascade
|
|
|
|
field payment_method_id blob
|
|
|
|
|
|
|
|
field created_at timestamp ( autoinsert )
|
|
|
|
)
|
|
|
|
|
|
|
|
create project_payment ( )
|
|
|
|
|
|
|
|
read one (
|
|
|
|
select project_payment
|
|
|
|
where project_payment.project_id = ?
|
|
|
|
)
|
|
|
|
read one (
|
|
|
|
select project_payment
|
|
|
|
where project_payment.payer_id = ?
|
|
|
|
)
|
|
|
|
|
|
|
|
model project_invoice_stamp (
|
|
|
|
key project_id start_date end_date
|
|
|
|
unique invoice_id
|
|
|
|
|
|
|
|
field project_id project.id cascade
|
|
|
|
field invoice_id blob
|
|
|
|
|
|
|
|
field start_date timestamp
|
|
|
|
field end_date timestamp
|
|
|
|
|
|
|
|
field created_at timestamp
|
|
|
|
)
|
|
|
|
|
|
|
|
create project_invoice_stamp ( )
|
|
|
|
|
|
|
|
read one (
|
|
|
|
select project_invoice_stamp
|
|
|
|
where project_invoice_stamp.project_id = ?
|
|
|
|
where project_invoice_stamp.start_date = ?
|
|
|
|
)
|
|
|
|
// pagination ?
|
|
|
|
read all (
|
|
|
|
select project_invoice_stamp
|
|
|
|
where project_invoice_stamp.project_id = ?
|
|
|
|
orderby desc project_invoice_stamp.start_date
|
|
|
|
)
|
2019-01-16 20:23:28 +00:00
|
|
|
|
|
|
|
model project_member (
|
|
|
|
key member_id project_id
|
|
|
|
|
|
|
|
field member_id user.id cascade
|
|
|
|
field project_id project.id cascade
|
|
|
|
|
|
|
|
field created_at timestamp ( autoinsert )
|
|
|
|
)
|
|
|
|
|
2019-06-06 17:07:14 +01:00
|
|
|
create project_member ( )
|
|
|
|
delete project_member (
|
|
|
|
where project_member.member_id = ?
|
|
|
|
where project_member.project_id = ?
|
|
|
|
)
|
|
|
|
|
2019-01-16 20:23:28 +00:00
|
|
|
read all (
|
|
|
|
select project_member
|
|
|
|
where project_member.member_id = ?
|
|
|
|
)
|
|
|
|
read limitoffset (
|
|
|
|
select project_member
|
|
|
|
where project_member.project_id = ?
|
|
|
|
)
|
|
|
|
|
|
|
|
model api_key (
|
2019-03-06 15:54:48 +00:00
|
|
|
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-03-06 15:54:48 +00:00
|
|
|
field id blob
|
|
|
|
field project_id project.id cascade
|
2019-05-24 17:51:27 +01:00
|
|
|
field head blob
|
2019-03-06 15:54:48 +00:00
|
|
|
field name text (updatable)
|
2019-05-24 17:51:27 +01:00
|
|
|
field secret blob
|
2019-03-06 15:54:48 +00:00
|
|
|
field created_at timestamp (autoinsert)
|
2019-01-16 20:23:28 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
create api_key ()
|
|
|
|
update api_key ( where api_key.id = ? )
|
|
|
|
delete api_key ( where api_key.id = ? )
|
|
|
|
|
|
|
|
read one (
|
|
|
|
select api_key
|
|
|
|
where api_key.id = ?
|
|
|
|
)
|
|
|
|
read one (
|
|
|
|
select api_key
|
2019-05-24 17:51:27 +01:00
|
|
|
where api_key.head = ?
|
2019-01-16 20:23:28 +00:00
|
|
|
)
|
|
|
|
read all (
|
|
|
|
select api_key
|
|
|
|
where api_key.project_id = ?
|
|
|
|
orderby asc api_key.name
|
2019-02-07 19:22:49 +00:00
|
|
|
)
|
|
|
|
|
2019-03-06 15:54:48 +00:00
|
|
|
//-----bucket_usage----//
|
|
|
|
|
|
|
|
model bucket_usage (
|
|
|
|
key id
|
2019-03-26 10:34:30 +00:00
|
|
|
index (
|
|
|
|
name bucket_id_rollup
|
|
|
|
fields bucket_id rollup_end_time
|
|
|
|
unique
|
|
|
|
)
|
2019-03-06 15:54:48 +00:00
|
|
|
|
|
|
|
field id blob
|
|
|
|
field bucket_id blob //--TODO: add foreign key constraint--//
|
|
|
|
|
|
|
|
field rollup_end_time timestamp
|
|
|
|
|
|
|
|
field remote_stored_data uint64
|
|
|
|
field inline_stored_data uint64
|
|
|
|
field remote_segments uint
|
|
|
|
field inline_segments uint
|
|
|
|
field objects uint
|
|
|
|
field metadata_size uint64
|
|
|
|
field repair_egress uint64
|
|
|
|
field get_egress uint64
|
|
|
|
field audit_egress uint64
|
|
|
|
)
|
|
|
|
|
|
|
|
create bucket_usage ()
|
|
|
|
delete bucket_usage ( where bucket_usage.id = ? )
|
|
|
|
|
|
|
|
read one (
|
|
|
|
select bucket_usage
|
|
|
|
where bucket_usage.id = ?
|
|
|
|
)
|
|
|
|
read limitoffset (
|
|
|
|
select bucket_usage
|
|
|
|
where bucket_usage.bucket_id = ?
|
|
|
|
where bucket_usage.rollup_end_time > ?
|
|
|
|
where bucket_usage.rollup_end_time <= ?
|
|
|
|
orderby asc bucket_usage.rollup_end_time
|
|
|
|
)
|
|
|
|
read limitoffset (
|
|
|
|
select bucket_usage
|
|
|
|
where bucket_usage.bucket_id = ?
|
|
|
|
where bucket_usage.rollup_end_time > ?
|
|
|
|
where bucket_usage.rollup_end_time <= ?
|
|
|
|
orderby desc bucket_usage.rollup_end_time
|
|
|
|
)
|
|
|
|
|
2019-03-22 18:54:22 +00:00
|
|
|
//--- tracking serial numbers ---//
|
|
|
|
|
|
|
|
model serial_number (
|
|
|
|
key id
|
2019-03-26 10:34:30 +00:00
|
|
|
index (
|
|
|
|
name serial_number
|
|
|
|
fields serial_number
|
|
|
|
unique
|
|
|
|
)
|
2019-03-22 18:54:22 +00:00
|
|
|
|
|
|
|
field id serial
|
|
|
|
field serial_number blob
|
|
|
|
|
|
|
|
field bucket_id blob
|
|
|
|
field expires_at utimestamp
|
|
|
|
|
|
|
|
index (
|
|
|
|
fields expires_at
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
model used_serial (
|
2019-03-26 10:34:30 +00:00
|
|
|
key serial_number_id storage_node_id
|
2019-03-22 18:54:22 +00:00
|
|
|
|
|
|
|
field serial_number_id serial_number.id cascade
|
|
|
|
field storage_node_id blob
|
|
|
|
)
|
|
|
|
|
|
|
|
// inserting a new serial number
|
|
|
|
create serial_number ()
|
|
|
|
|
|
|
|
// finding out information about the serial number
|
|
|
|
read scalar (
|
|
|
|
select serial_number
|
|
|
|
where serial_number.serial_number = ?
|
|
|
|
)
|
|
|
|
|
|
|
|
// deleting expired serial numbers
|
|
|
|
delete serial_number (
|
|
|
|
where serial_number.expires_at <= ?
|
|
|
|
)
|
|
|
|
|
|
|
|
// for preventing duplicate serial numbers
|
|
|
|
create used_serial ()
|
|
|
|
|
2019-03-28 02:46:49 +00:00
|
|
|
// --- bucket accounting tables --- //
|
2019-03-22 18:54:22 +00:00
|
|
|
|
|
|
|
model bucket_bandwidth_rollup (
|
2019-04-02 19:21:18 +01:00
|
|
|
key bucket_name project_id interval_start action
|
2019-03-26 10:34:30 +00:00
|
|
|
index (
|
2019-04-02 19:21:18 +01:00
|
|
|
name bucket_name_project_id_interval_start_interval_seconds
|
|
|
|
fields bucket_name project_id interval_start interval_seconds
|
2019-03-26 10:34:30 +00:00
|
|
|
)
|
2019-03-22 18:54:22 +00:00
|
|
|
|
2019-04-02 19:21:18 +01:00
|
|
|
field bucket_name blob
|
|
|
|
field project_id blob
|
|
|
|
|
2019-03-22 18:54:22 +00:00
|
|
|
field interval_start utimestamp
|
|
|
|
field interval_seconds uint
|
|
|
|
field action uint
|
|
|
|
|
2019-04-01 21:14:58 +01:00
|
|
|
field inline uint64 ( updatable )
|
|
|
|
field allocated uint64 ( updatable )
|
|
|
|
field settled uint64 ( updatable )
|
|
|
|
)
|
|
|
|
|
|
|
|
read scalar (
|
|
|
|
select bucket_bandwidth_rollup
|
2019-04-02 19:21:18 +01:00
|
|
|
where bucket_bandwidth_rollup.bucket_name = ?
|
|
|
|
where bucket_bandwidth_rollup.project_id = ?
|
2019-04-01 21:14:58 +01:00
|
|
|
where bucket_bandwidth_rollup.interval_start = ?
|
|
|
|
where bucket_bandwidth_rollup.action = ?
|
2019-03-22 18:54:22 +00:00
|
|
|
)
|
|
|
|
|
2019-03-28 02:46:49 +00:00
|
|
|
model bucket_storage_tally (
|
2019-04-02 19:21:18 +01:00
|
|
|
key bucket_name project_id interval_start
|
|
|
|
|
|
|
|
field bucket_name blob
|
|
|
|
field project_id blob
|
2019-03-22 18:54:22 +00:00
|
|
|
|
|
|
|
field interval_start utimestamp
|
|
|
|
|
|
|
|
field inline uint64
|
|
|
|
field remote uint64
|
2019-04-10 07:04:24 +01:00
|
|
|
|
2019-03-28 02:46:49 +00:00
|
|
|
field remote_segments_count uint
|
|
|
|
field inline_segments_count uint
|
|
|
|
field object_count uint
|
|
|
|
|
|
|
|
field metadata_size uint64
|
2019-03-22 18:54:22 +00:00
|
|
|
)
|
|
|
|
|
2019-04-02 19:21:18 +01:00
|
|
|
create bucket_storage_tally ()
|
|
|
|
|
|
|
|
read first (
|
|
|
|
select bucket_storage_tally
|
|
|
|
where bucket_storage_tally.project_id = ?
|
|
|
|
orderby desc bucket_storage_tally.interval_start
|
|
|
|
)
|
2019-04-01 14:42:17 +01:00
|
|
|
|
2019-04-04 15:56:20 +01:00
|
|
|
read all (
|
|
|
|
select bucket_storage_tally
|
|
|
|
where bucket_storage_tally.project_id = ?
|
|
|
|
where bucket_storage_tally.bucket_name = ?
|
|
|
|
where bucket_storage_tally.interval_start >= ?
|
|
|
|
where bucket_storage_tally.interval_start <= ?
|
|
|
|
orderby desc bucket_storage_tally.interval_start
|
|
|
|
)
|
|
|
|
|
2019-03-28 02:46:49 +00:00
|
|
|
// --- storage node accounting tables --- //
|
2019-03-22 18:54:22 +00:00
|
|
|
|
|
|
|
model storagenode_bandwidth_rollup (
|
2019-03-26 10:34:30 +00:00
|
|
|
key storagenode_id interval_start action
|
|
|
|
index (
|
|
|
|
name storagenode_id_interval_start_interval_seconds
|
|
|
|
fields storagenode_id interval_start interval_seconds
|
|
|
|
)
|
2019-03-22 18:54:22 +00:00
|
|
|
|
|
|
|
field storagenode_id blob
|
|
|
|
field interval_start utimestamp
|
|
|
|
field interval_seconds uint
|
|
|
|
field action uint
|
|
|
|
|
2019-04-01 21:14:58 +01:00
|
|
|
field allocated uint64 ( updatable )
|
|
|
|
field settled uint64 ( updatable )
|
|
|
|
)
|
|
|
|
|
|
|
|
read scalar (
|
|
|
|
select storagenode_bandwidth_rollup
|
|
|
|
where storagenode_bandwidth_rollup.storagenode_id = ?
|
|
|
|
where storagenode_bandwidth_rollup.interval_start = ?
|
|
|
|
where storagenode_bandwidth_rollup.action = ?
|
2019-03-22 18:54:22 +00:00
|
|
|
)
|
|
|
|
|
2019-04-04 16:20:59 +01:00
|
|
|
read all (
|
|
|
|
select storagenode_bandwidth_rollup
|
|
|
|
where storagenode_bandwidth_rollup.interval_start >= ?
|
|
|
|
)
|
|
|
|
|
2019-03-28 02:46:49 +00:00
|
|
|
model storagenode_storage_tally (
|
2019-05-10 20:05:42 +01:00
|
|
|
key id
|
2019-05-24 17:51:27 +01:00
|
|
|
|
2019-05-10 20:05:42 +01:00
|
|
|
field id serial64
|
|
|
|
field node_id blob
|
|
|
|
field interval_end_time timestamp
|
|
|
|
field data_total float64
|
|
|
|
)
|
2019-03-22 18:54:22 +00:00
|
|
|
|
2019-05-10 20:05:42 +01:00
|
|
|
create storagenode_storage_tally ()
|
|
|
|
delete storagenode_storage_tally ( where storagenode_storage_tally.id = ? )
|
|
|
|
read one (
|
|
|
|
select storagenode_storage_tally
|
|
|
|
where storagenode_storage_tally.id = ?
|
|
|
|
)
|
|
|
|
read all (
|
|
|
|
select storagenode_storage_tally
|
|
|
|
)
|
|
|
|
read all (
|
|
|
|
select storagenode_storage_tally
|
|
|
|
where storagenode_storage_tally.interval_end_time >= ?
|
2019-03-22 18:54:22 +00:00
|
|
|
)
|
|
|
|
|
2019-02-07 19:22:49 +00:00
|
|
|
//--- certRecord ---//
|
|
|
|
|
|
|
|
model certRecord (
|
2019-04-10 07:04:24 +01:00
|
|
|
key id
|
2019-02-07 19:22:49 +00:00
|
|
|
|
|
|
|
field publickey blob //--uplink public key--//
|
|
|
|
field id blob //--uplink node id --//
|
|
|
|
field update_at timestamp ( autoinsert, autoupdate )
|
|
|
|
)
|
|
|
|
|
|
|
|
create certRecord ( )
|
|
|
|
delete certRecord ( where certRecord.id = ? )
|
|
|
|
update certRecord ( where certRecord.id = ? )
|
|
|
|
|
|
|
|
read one (
|
|
|
|
select certRecord
|
|
|
|
where certRecord.id = ?
|
|
|
|
)
|
2019-03-19 17:55:43 +00:00
|
|
|
|
|
|
|
//--- satellite registration token for Vanguard release (temporary table) ---//
|
|
|
|
|
|
|
|
model registration_token (
|
|
|
|
key secret
|
|
|
|
unique owner_id
|
|
|
|
|
|
|
|
field secret blob
|
|
|
|
field owner_id blob ( updatable, nullable )
|
|
|
|
|
|
|
|
field project_limit int
|
|
|
|
|
|
|
|
field created_at timestamp ( autoinsert )
|
|
|
|
)
|
|
|
|
|
|
|
|
create registration_token ( )
|
|
|
|
read one (
|
|
|
|
select registration_token
|
|
|
|
where registration_token.secret = ?
|
|
|
|
)
|
|
|
|
read one (
|
|
|
|
select registration_token
|
|
|
|
where registration_token.owner_id = ?
|
|
|
|
)
|
|
|
|
update registration_token ( where registration_token.secret = ? )
|
2019-05-13 16:53:52 +01:00
|
|
|
|
|
|
|
//--- satellite reset password token ---//
|
|
|
|
|
|
|
|
model reset_password_token (
|
|
|
|
key secret
|
|
|
|
unique owner_id
|
|
|
|
|
|
|
|
field secret blob
|
|
|
|
field owner_id blob ( updatable )
|
|
|
|
|
|
|
|
field created_at timestamp ( autoinsert )
|
|
|
|
)
|
|
|
|
|
|
|
|
create reset_password_token ( )
|
|
|
|
read one (
|
|
|
|
select reset_password_token
|
|
|
|
where reset_password_token.secret = ?
|
|
|
|
)
|
|
|
|
read one (
|
|
|
|
select reset_password_token
|
|
|
|
where reset_password_token.owner_id = ?
|
|
|
|
)
|
|
|
|
delete reset_password_token ( where reset_password_token.secret = ? )
|
2019-05-22 22:41:55 +01:00
|
|
|
|
|
|
|
|
|
|
|
//--- offer table ---//
|
|
|
|
|
|
|
|
model offer (
|
|
|
|
key id
|
2019-06-18 10:14:31 +01:00
|
|
|
|
|
|
|
field id serial
|
2019-05-22 22:41:55 +01:00
|
|
|
field name text ( updatable )
|
|
|
|
field description text ( updatable )
|
2019-06-13 14:52:33 +01:00
|
|
|
|
|
|
|
field award_credit_in_cents int ( updatable )
|
2019-06-04 20:17:01 +01:00
|
|
|
field invitee_credit_in_cents int ( updatable )
|
|
|
|
|
2019-05-22 22:41:55 +01:00
|
|
|
field award_credit_duration_days int ( updatable )
|
|
|
|
field invitee_credit_duration_days int ( updatable )
|
|
|
|
|
|
|
|
field redeemable_cap int ( updatable )
|
|
|
|
field num_redeemed int ( updatable, autoinsert )
|
|
|
|
|
2019-06-04 20:17:01 +01:00
|
|
|
field expires_at timestamp ( updatable )
|
2019-05-22 22:41:55 +01:00
|
|
|
field created_at timestamp ( autoinsert )
|
|
|
|
|
2019-07-08 19:39:56 +01:00
|
|
|
// status corresponds to the values of rewards.OfferStatus
|
2019-06-04 20:17:01 +01:00
|
|
|
field status int ( updatable )
|
2019-07-08 19:39:56 +01:00
|
|
|
// type corresponds to the values of rewards.OfferType
|
2019-06-04 20:17:01 +01:00
|
|
|
field type int ( updatable )
|
2019-05-22 22:41:55 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
read one (
|
|
|
|
select offer
|
|
|
|
where offer.id = ?
|
|
|
|
)
|
|
|
|
|
2019-06-04 20:17:01 +01:00
|
|
|
read all (
|
2019-05-22 22:41:55 +01:00
|
|
|
select offer
|
|
|
|
)
|
|
|
|
|
|
|
|
update offer (
|
|
|
|
where offer.id = ?
|
|
|
|
)
|
|
|
|
|
2019-06-04 20:17:01 +01:00
|
|
|
create offer ( )
|
2019-06-13 14:52:33 +01:00
|
|
|
|
|
|
|
|
|
|
|
//--- user credit table ---//
|
|
|
|
|
|
|
|
model user_credit (
|
|
|
|
key id
|
|
|
|
|
|
|
|
field id serial
|
|
|
|
|
|
|
|
field user_id user.id restrict
|
|
|
|
field offer_id offer.id restrict
|
|
|
|
field referred_by user.id restrict ( nullable )
|
|
|
|
|
|
|
|
field credits_earned_in_cents int
|
|
|
|
field credits_used_in_cents int ( updatable, autoinsert )
|
|
|
|
|
|
|
|
field expires_at timestamp ( updatable )
|
|
|
|
field created_at timestamp ( autoinsert )
|
|
|
|
)
|
|
|
|
|
|
|
|
read all (
|
|
|
|
select user_credit
|
|
|
|
where user_credit.user_id = ?
|
|
|
|
where user_credit.expires_at > ?
|
|
|
|
where user_credit.credits_used_in_cents < user_credit.credits_earned_in_cents
|
|
|
|
orderby asc user_credit.expires_at
|
|
|
|
)
|
|
|
|
|
|
|
|
read count (
|
|
|
|
select user_credit
|
|
|
|
where user_credit.referred_by = ?
|
|
|
|
)
|
|
|
|
|
|
|
|
create user_credit ()
|
2019-07-01 21:45:21 +01:00
|
|
|
|
|
|
|
//--- metainfo buckets ---//
|
|
|
|
|
2019-07-03 23:03:56 +01:00
|
|
|
model bucket_metainfo (
|
2019-07-01 21:45:21 +01:00
|
|
|
key id
|
|
|
|
unique name project_id
|
|
|
|
|
|
|
|
field id blob
|
|
|
|
field project_id project.id restrict
|
|
|
|
field name blob
|
|
|
|
|
|
|
|
field path_cipher int
|
|
|
|
|
|
|
|
field created_at timestamp ( autoinsert )
|
|
|
|
|
|
|
|
field default_segment_size int (updatable)
|
|
|
|
|
|
|
|
field default_encryption_cipher_suite int (updatable)
|
|
|
|
field default_encryption_block_size int (updatable)
|
|
|
|
|
|
|
|
field default_redundancy_algorithm int (updatable)
|
|
|
|
field default_redundancy_share_size int (updatable)
|
|
|
|
field default_redundancy_required_shares int (updatable)
|
|
|
|
field default_redundancy_repair_shares int (updatable)
|
|
|
|
field default_redundancy_optimal_shares int (updatable)
|
|
|
|
field default_redundancy_total_shares int (updatable)
|
|
|
|
)
|
|
|
|
|
2019-07-03 23:03:56 +01:00
|
|
|
create bucket_metainfo ()
|
2019-07-01 21:45:21 +01:00
|
|
|
|
|
|
|
read one (
|
2019-07-03 23:03:56 +01:00
|
|
|
select bucket_metainfo
|
|
|
|
where bucket_metainfo.project_id = ?
|
|
|
|
where bucket_metainfo.name = ?
|
2019-07-01 21:45:21 +01:00
|
|
|
)
|
|
|
|
|
2019-07-03 23:03:56 +01:00
|
|
|
delete bucket_metainfo (
|
|
|
|
where bucket_metainfo.project_id = ?
|
|
|
|
where bucket_metainfo.name = ?
|
2019-07-01 21:45:21 +01:00
|
|
|
)
|
2019-07-08 23:32:18 +01:00
|
|
|
|
|
|
|
read limitoffset ( // Forward
|
|
|
|
select bucket_metainfo
|
|
|
|
where bucket_metainfo.project_id = ?
|
|
|
|
where bucket_metainfo.name >= ?
|
|
|
|
orderby asc bucket_metainfo.name
|
|
|
|
)
|