2018-12-05 09:35:50 +00:00
|
|
|
// dbx.v1 golang satellitedb.dbx .
|
|
|
|
|
2018-12-14 14:27:21 +00:00
|
|
|
//--- bwagreement ---//
|
|
|
|
|
2018-12-07 09:59:31 +00:00
|
|
|
model bwagreement (
|
2019-01-28 21:16:21 +00:00
|
|
|
key serialnum
|
2018-12-05 09:35:50 +00:00
|
|
|
|
2019-01-28 21:16:21 +00:00
|
|
|
field serialnum text
|
|
|
|
field data blob
|
|
|
|
field storage_node blob
|
|
|
|
field action int64
|
|
|
|
field total int64
|
2018-12-07 09:59:31 +00:00
|
|
|
field created_at timestamp ( autoinsert )
|
2019-01-10 18:30:55 +00:00
|
|
|
field expires_at timestamp
|
2018-12-07 09:59:31 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
create bwagreement ( )
|
2019-01-28 21:16:21 +00:00
|
|
|
delete bwagreement ( where bwagreement.serialnum = ? )
|
2019-01-10 18:30:55 +00:00
|
|
|
delete bwagreement ( where bwagreement.expires_at <= ?)
|
2018-12-27 21:21:50 +00:00
|
|
|
|
2018-12-07 09:59:31 +00:00
|
|
|
read one (
|
2018-12-27 21:21:50 +00:00
|
|
|
select bwagreement
|
2019-01-28 21:16:21 +00:00
|
|
|
where bwagreement.serialnum = ?
|
2018-12-07 09:59:31 +00:00
|
|
|
)
|
2018-12-27 21:21:50 +00:00
|
|
|
|
2018-12-07 09:59:31 +00:00
|
|
|
read limitoffset (
|
|
|
|
select bwagreement
|
|
|
|
)
|
2018-12-27 21:21:50 +00:00
|
|
|
|
2018-12-07 09:59:31 +00:00
|
|
|
read all (
|
|
|
|
select bwagreement
|
|
|
|
)
|
2018-12-27 21:21:50 +00:00
|
|
|
|
2018-12-07 09:59:31 +00:00
|
|
|
read all (
|
|
|
|
select bwagreement
|
|
|
|
where bwagreement.created_at > ?
|
2018-12-10 19:08:45 +00:00
|
|
|
)
|
|
|
|
|
2018-12-14 14:27:21 +00:00
|
|
|
//--- datarepair.irreparableDB ---//
|
|
|
|
|
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
|
|
|
)
|
|
|
|
|
|
|
|
//--- 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
|
|
|
|
field get_repair_total int64
|
|
|
|
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
|
|
|
model accounting_raw (
|
2018-12-27 21:21:50 +00:00
|
|
|
key id
|
2018-12-14 14:27:21 +00:00
|
|
|
|
2018-12-27 21:21:50 +00:00
|
|
|
field id serial64
|
2019-01-16 19:30:33 +00:00
|
|
|
field node_id blob
|
2018-12-27 21:21:50 +00:00
|
|
|
field interval_end_time timestamp
|
2019-01-16 19:30:33 +00:00
|
|
|
field data_total float64
|
2018-12-27 21:21:50 +00:00
|
|
|
field data_type int
|
|
|
|
field created_at timestamp ( autoinsert )
|
2018-12-14 14:27:21 +00:00
|
|
|
)
|
|
|
|
|
2018-12-18 17:18:42 +00:00
|
|
|
create accounting_raw ( )
|
|
|
|
delete accounting_raw ( where accounting_raw.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_raw
|
|
|
|
where accounting_raw.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_raw
|
2019-01-16 19:30:33 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
read all (
|
|
|
|
select accounting_raw
|
|
|
|
where accounting_raw.interval_end_time >= ?
|
2018-12-14 20:17:30 +00:00
|
|
|
)
|
2018-12-18 17:18:42 +00:00
|
|
|
|
|
|
|
//--- statdb ---//
|
|
|
|
|
2018-12-14 20:17:30 +00:00
|
|
|
model node (
|
|
|
|
key id
|
|
|
|
|
2018-12-27 21:21:50 +00:00
|
|
|
field id blob
|
|
|
|
field audit_success_count int64 ( updatable )
|
|
|
|
field total_audit_count int64 ( updatable )
|
|
|
|
field audit_success_ratio float64 ( updatable )
|
2018-12-14 20:17:30 +00:00
|
|
|
|
2018-12-27 21:21:50 +00:00
|
|
|
field uptime_success_count int64 ( updatable )
|
|
|
|
field total_uptime_count int64 ( updatable )
|
|
|
|
field uptime_ratio float64 ( updatable )
|
2018-12-14 20:17:30 +00:00
|
|
|
|
|
|
|
field created_at timestamp ( autoinsert )
|
|
|
|
field updated_at timestamp ( autoinsert, autoupdate )
|
|
|
|
)
|
|
|
|
|
|
|
|
create node ( )
|
|
|
|
update node ( where node.id = ? )
|
|
|
|
delete node ( where node.id = ? )
|
2018-12-27 21:21:50 +00:00
|
|
|
|
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
|
|
|
|
)
|
|
|
|
|
|
|
|
// payment csv generation query
|
|
|
|
read all (
|
|
|
|
select node.id node.created_at node.audit_success_ratio accounting_rollup.start_time accounting_rollup.put_total accounting_rollup.get_total accounting_rollup.get_audit_total accounting_rollup.get_repair_total accounting_rollup.put_repair_total accounting_rollup.at_rest_total
|
|
|
|
where accounting_rollup.start_time >= ?
|
|
|
|
where accounting_rollup.start_time < ?
|
|
|
|
join node.id = accounting_rollup.node_id
|
|
|
|
orderby asc node.id
|
|
|
|
)
|
|
|
|
|
2018-12-17 20:14:16 +00:00
|
|
|
//--- overlaycache ---//
|
|
|
|
|
|
|
|
model overlay_cache_node (
|
2019-01-15 16:08:45 +00:00
|
|
|
key node_id
|
|
|
|
unique node_id
|
2018-12-17 20:14:16 +00:00
|
|
|
|
2019-01-15 16:08:45 +00:00
|
|
|
field node_id blob
|
|
|
|
field node_type int
|
|
|
|
|
|
|
|
field address text (updatable) // TODO: use compressed format
|
|
|
|
field protocol int (updatable)
|
|
|
|
|
|
|
|
field operator_email text (updatable)
|
|
|
|
field operator_wallet text (updatable) //TODO: use compressed format
|
|
|
|
|
|
|
|
field free_bandwidth int64 (updatable)
|
|
|
|
field free_disk int64 (updatable)
|
|
|
|
|
|
|
|
field latency_90 int64 (updatable)
|
|
|
|
|
|
|
|
field audit_success_ratio float64 (updatable)
|
|
|
|
field audit_uptime_ratio float64 (updatable)
|
|
|
|
field audit_count int64 (updatable)
|
|
|
|
field audit_success_count int64 (updatable)
|
|
|
|
|
|
|
|
field uptime_count int64 (updatable)
|
|
|
|
field uptime_success_count int64 (updatable)
|
2018-12-17 20:14:16 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
create overlay_cache_node ( )
|
|
|
|
|
|
|
|
read one (
|
2018-12-27 21:21:50 +00:00
|
|
|
select overlay_cache_node
|
2019-01-15 16:08:45 +00:00
|
|
|
where overlay_cache_node.node_id = ?
|
2018-12-18 20:41:31 +00:00
|
|
|
)
|
|
|
|
|
2019-01-17 18:34:13 +00:00
|
|
|
read one (
|
|
|
|
select overlay_cache_node.operator_wallet
|
|
|
|
where overlay_cache_node.node_id = ?
|
|
|
|
)
|
|
|
|
|
2018-12-17 20:14:16 +00:00
|
|
|
read limitoffset (
|
|
|
|
select overlay_cache_node
|
2019-01-15 16:08:45 +00:00
|
|
|
where overlay_cache_node.node_id >= ?
|
2018-12-17 20:14:16 +00:00
|
|
|
)
|
|
|
|
|
2019-01-15 16:08:45 +00:00
|
|
|
update overlay_cache_node ( where overlay_cache_node.node_id = ? )
|
|
|
|
delete overlay_cache_node ( where overlay_cache_node.node_id = ? )
|
2018-12-21 15:11:19 +00:00
|
|
|
|
|
|
|
//--- repairqueue ---//
|
|
|
|
|
|
|
|
model injuredsegment (
|
2018-12-27 21:21:50 +00:00
|
|
|
key id
|
2018-12-21 15:11:19 +00:00
|
|
|
|
2018-12-27 21:21:50 +00:00
|
|
|
field id serial64
|
2018-12-21 15:11:19 +00:00
|
|
|
field info blob
|
|
|
|
)
|
|
|
|
|
|
|
|
create injuredsegment ( )
|
2018-12-27 21:21:50 +00:00
|
|
|
|
2018-12-21 15:11:19 +00:00
|
|
|
read first (
|
|
|
|
select injuredsegment
|
|
|
|
)
|
2018-12-27 21:21:50 +00:00
|
|
|
|
2018-12-21 15:11:19 +00:00
|
|
|
read limitoffset (
|
|
|
|
select injuredsegment
|
|
|
|
)
|
2018-12-27 09:56:25 +00:00
|
|
|
delete injuredsegment ( where injuredsegment.id = ? )
|
2019-01-16 20:23:28 +00:00
|
|
|
|
|
|
|
//--- satellite console ---//
|
|
|
|
|
|
|
|
model user (
|
|
|
|
key id
|
|
|
|
unique email
|
|
|
|
|
2019-01-30 15:04:40 +00:00
|
|
|
field id blob
|
|
|
|
field first_name text ( updatable )
|
|
|
|
field last_name text ( updatable )
|
2019-01-16 20:23:28 +00:00
|
|
|
|
2019-01-30 15:04:40 +00:00
|
|
|
field email text ( updatable, nullable )
|
|
|
|
field password_hash blob ( updatable )
|
|
|
|
|
|
|
|
field created_at timestamp ( autoinsert )
|
2019-01-16 20:23:28 +00:00
|
|
|
)
|
|
|
|
read one (
|
|
|
|
select user
|
|
|
|
where user.email = ?
|
|
|
|
)
|
|
|
|
read one (
|
|
|
|
select user
|
|
|
|
where user.id = ?
|
|
|
|
)
|
|
|
|
create user ( )
|
|
|
|
update user ( where user.id = ? )
|
|
|
|
delete user ( where user.id = ? )
|
|
|
|
|
|
|
|
|
|
|
|
model project (
|
|
|
|
key id
|
|
|
|
|
|
|
|
field id blob
|
|
|
|
|
|
|
|
field name text
|
|
|
|
field description text ( updatable )
|
|
|
|
|
|
|
|
field created_at timestamp ( autoinsert )
|
|
|
|
)
|
|
|
|
read all ( select project)
|
|
|
|
read one (
|
|
|
|
select project
|
|
|
|
where project.id = ?
|
|
|
|
)
|
|
|
|
read all (
|
|
|
|
select project
|
|
|
|
join project.id = project_member.project_id
|
|
|
|
where project_member.member_id = ?
|
|
|
|
orderby asc project.name
|
|
|
|
)
|
|
|
|
create project ( )
|
|
|
|
update project ( where project.id = ? )
|
|
|
|
delete project ( where project.id = ? )
|
|
|
|
|
|
|
|
|
|
|
|
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 )
|
|
|
|
)
|
|
|
|
|
|
|
|
read all (
|
|
|
|
select project_member
|
|
|
|
where project_member.member_id = ?
|
|
|
|
)
|
|
|
|
read limitoffset (
|
|
|
|
select project_member
|
|
|
|
where project_member.project_id = ?
|
|
|
|
)
|
|
|
|
create project_member ( )
|
|
|
|
delete project_member (
|
|
|
|
where project_member.member_id = ?
|
|
|
|
where project_member.project_id = ?
|
|
|
|
)
|
|
|
|
|
|
|
|
model api_key (
|
|
|
|
key id
|
|
|
|
unique key
|
|
|
|
unique name project_id
|
|
|
|
|
|
|
|
field id blob
|
|
|
|
field project_id project.id cascade
|
|
|
|
|
|
|
|
field key blob
|
|
|
|
|
|
|
|
field name text (updatable)
|
|
|
|
|
|
|
|
field created_at timestamp ( autoinsert )
|
|
|
|
)
|
|
|
|
|
|
|
|
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
|
|
|
|
where api_key.key = ?
|
|
|
|
)
|
|
|
|
read all (
|
|
|
|
select api_key
|
|
|
|
where api_key.project_id = ?
|
|
|
|
orderby asc api_key.name
|
|
|
|
)
|
|
|
|
|
|
|
|
model bucket_info (
|
|
|
|
key name
|
|
|
|
|
|
|
|
field project_id project.id cascade
|
|
|
|
|
|
|
|
field name text
|
|
|
|
|
|
|
|
field created_at timestamp ( autoinsert )
|
|
|
|
)
|
|
|
|
|
|
|
|
create bucket_info ()
|
|
|
|
delete bucket_info ( where bucket_info.name = ? )
|
|
|
|
|
|
|
|
read one (
|
|
|
|
select bucket_info
|
|
|
|
where bucket_info.name = ?
|
|
|
|
)
|
|
|
|
|
|
|
|
read all (
|
|
|
|
select bucket_info
|
|
|
|
where bucket_info.project_id = ?
|
|
|
|
orderby asc bucket_info.name
|
|
|
|
)
|