2023-02-23 15:35:55 +00:00
|
|
|
// stripe_customer contains the user Stripe information.
|
2023-01-06 16:27:42 +00:00
|
|
|
model stripe_customer (
|
2023-02-23 15:35:55 +00:00
|
|
|
key user_id
|
|
|
|
unique customer_id
|
|
|
|
|
|
|
|
// user_id refers to user.id.
|
|
|
|
field user_id blob
|
|
|
|
// customer_id is the Stripe customer identifier.
|
|
|
|
field customer_id text
|
|
|
|
// created_at is the time the customer was first added.
|
|
|
|
field created_at timestamp ( autoinsert )
|
2023-01-06 16:27:42 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
create stripe_customer ( )
|
|
|
|
|
|
|
|
read one (
|
|
|
|
select stripe_customer.customer_id
|
|
|
|
where stripe_customer.user_id = ?
|
|
|
|
)
|
2023-02-13 17:32:39 +00:00
|
|
|
read one (
|
|
|
|
select stripe_customer.user_id
|
|
|
|
where stripe_customer.customer_id = ?
|
|
|
|
)
|
2023-01-06 16:27:42 +00:00
|
|
|
read limitoffset (
|
2023-02-23 15:35:55 +00:00
|
|
|
select stripe_customer
|
|
|
|
where stripe_customer.created_at <= ?
|
|
|
|
orderby desc stripe_customer.created_at
|
2023-01-06 16:27:42 +00:00
|
|
|
)
|
|
|
|
|
2023-02-23 15:35:55 +00:00
|
|
|
// billing_balance is the current balance for the user.
|
2023-01-06 16:27:42 +00:00
|
|
|
model billing_balance (
|
2023-02-23 15:35:55 +00:00
|
|
|
key user_id
|
|
|
|
|
|
|
|
// user_id refers to user.id.
|
|
|
|
field user_id blob
|
|
|
|
// balance is the currency in base units, which for USD is in cents.
|
|
|
|
field balance int64 ( updatable )
|
|
|
|
// last_updated is when the balance was last updated.
|
|
|
|
field last_updated timestamp ( autoinsert, autoupdate )
|
2023-01-06 16:27:42 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
create billing_balance ( noreturn )
|
|
|
|
|
|
|
|
update billing_balance (
|
2023-02-23 15:35:55 +00:00
|
|
|
where billing_balance.user_id = ?
|
|
|
|
where billing_balance.balance = ?
|
2023-01-06 16:27:42 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
read one (
|
|
|
|
select billing_balance.balance
|
|
|
|
where billing_balance.user_id = ?
|
|
|
|
)
|
|
|
|
|
2023-02-23 15:35:55 +00:00
|
|
|
// billing_transaction holds deposit information to the satellite.
|
2023-01-06 16:27:42 +00:00
|
|
|
model billing_transaction (
|
2023-02-23 15:35:55 +00:00
|
|
|
key id
|
|
|
|
|
|
|
|
// id is a unique identifier for the transaction.
|
|
|
|
field id serial64
|
|
|
|
// user_id refers to user.id.
|
|
|
|
field user_id blob
|
|
|
|
// amount is the amount of currency in base-units that was transferred.
|
|
|
|
field amount int64
|
|
|
|
// currency indicates which currency was used for the transaction.
|
|
|
|
field currency text
|
|
|
|
// description contains extra information about the transaction.
|
|
|
|
field description text
|
|
|
|
// source indicates where the transfer came from.
|
|
|
|
field source text
|
|
|
|
// status indicates the processing status of this transaction.
|
|
|
|
// It refers to billing.TransactionStatus, which can be "pending", "cancelled" or "complete".
|
|
|
|
field status text ( updatable )
|
|
|
|
// type indicates whether the transaction was credit or debit.
|
|
|
|
// The value refers to billing.TransactionType.
|
|
|
|
field type text
|
|
|
|
// metadata contains extra information about the transaction.
|
|
|
|
field metadata json ( updatable )
|
|
|
|
// timestamp is the time this transaction happened.
|
|
|
|
field timestamp timestamp
|
|
|
|
|
|
|
|
// created_at is the time the transaction was inserted into the table.
|
|
|
|
field created_at timestamp ( autoinsert )
|
|
|
|
|
|
|
|
index ( fields timestamp)
|
2023-01-06 16:27:42 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
create billing_transaction ( )
|
|
|
|
|
|
|
|
update billing_transaction (
|
2023-02-23 15:35:55 +00:00
|
|
|
where billing_transaction.id = ?
|
|
|
|
noreturn
|
2023-01-06 16:27:42 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
read one (
|
|
|
|
select billing_transaction.metadata
|
|
|
|
where billing_transaction.id = ?
|
|
|
|
)
|
|
|
|
|
|
|
|
read all (
|
2023-02-23 15:35:55 +00:00
|
|
|
select billing_transaction
|
|
|
|
where billing_transaction.user_id = ?
|
|
|
|
orderby desc billing_transaction.timestamp
|
2023-01-06 16:27:42 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
read first (
|
2023-02-23 15:35:55 +00:00
|
|
|
select billing_transaction
|
|
|
|
where billing_transaction.source = ?
|
|
|
|
where billing_transaction.type = ?
|
|
|
|
orderby ( desc billing_transaction.created_at)
|
2023-01-06 16:27:42 +00:00
|
|
|
)
|
|
|
|
|
2023-02-23 15:35:55 +00:00
|
|
|
// storjscan_wallet contains user wallet addresses.
|
2023-01-06 16:27:42 +00:00
|
|
|
model storjscan_wallet (
|
2023-02-23 15:35:55 +00:00
|
|
|
key user_id wallet_address
|
2023-01-06 16:27:42 +00:00
|
|
|
|
2023-02-23 15:35:55 +00:00
|
|
|
// user_id refers to user.id.
|
|
|
|
field user_id blob
|
|
|
|
// wallet_address is the wallet address which is associated with this user.
|
|
|
|
field wallet_address blob
|
|
|
|
// created_at is the time this wallet was added to the system.
|
|
|
|
field created_at timestamp ( autoinsert )
|
2023-01-06 16:27:42 +00:00
|
|
|
|
2023-02-23 15:35:55 +00:00
|
|
|
index ( fields wallet_address )
|
2023-01-06 16:27:42 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
create storjscan_wallet ( noreturn )
|
|
|
|
|
|
|
|
read one (
|
|
|
|
select storjscan_wallet.user_id
|
|
|
|
where storjscan_wallet.wallet_address = ?
|
|
|
|
)
|
|
|
|
|
|
|
|
read one (
|
|
|
|
select storjscan_wallet.wallet_address
|
|
|
|
where storjscan_wallet.user_id = ?
|
|
|
|
)
|
|
|
|
|
|
|
|
read all (
|
2023-02-23 15:35:55 +00:00
|
|
|
select storjscan_wallet
|
2023-01-06 16:27:42 +00:00
|
|
|
)
|
|
|
|
|
2023-02-23 15:35:55 +00:00
|
|
|
// coinpayments_transaction records information about a pending or finished coinpayment transactions.
|
2023-01-06 16:27:42 +00:00
|
|
|
model coinpayments_transaction (
|
2023-02-23 15:35:55 +00:00
|
|
|
key id
|
|
|
|
|
|
|
|
// id is the transaction identifier.
|
|
|
|
field id text
|
|
|
|
// user_id refers to user.id
|
|
|
|
field user_id blob
|
|
|
|
// address is the transaction address.
|
|
|
|
field address text
|
|
|
|
// amount_numeric is the amount in base units that should be paid.
|
|
|
|
field amount_numeric int64
|
|
|
|
// received_numeric is the actual amount in base units that was transferred.
|
|
|
|
field received_numeric int64 ( updatable )
|
|
|
|
// status is the status of this transaction. It refers to coinpayments.Status.
|
|
|
|
field status int ( updatable )
|
|
|
|
field key text
|
|
|
|
// timeout specifies how long the payer has time to send the specified amount.
|
|
|
|
field timeout int
|
|
|
|
|
|
|
|
// created_at is the time this transaction was added.
|
|
|
|
field created_at timestamp ( autoinsert )
|
2023-01-06 16:27:42 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
create coinpayments_transaction ()
|
|
|
|
update coinpayments_transaction ( where coinpayments_transaction.id = ? )
|
|
|
|
|
|
|
|
read all (
|
2023-02-23 15:35:55 +00:00
|
|
|
select coinpayments_transaction
|
|
|
|
where coinpayments_transaction.user_id = ?
|
|
|
|
orderby desc coinpayments_transaction.created_at
|
2023-01-06 16:27:42 +00:00
|
|
|
)
|
|
|
|
|
2023-02-23 15:35:55 +00:00
|
|
|
// stripecoinpayments_apply_balance_intent contains information about adding balance updates.
|
|
|
|
// This table seems unused at the moment.
|
2023-01-06 16:27:42 +00:00
|
|
|
model stripecoinpayments_apply_balance_intent (
|
2023-02-23 15:35:55 +00:00
|
|
|
key tx_id
|
2023-01-06 16:27:42 +00:00
|
|
|
|
2023-02-23 15:35:55 +00:00
|
|
|
// tx_id refers to to the transaction id.
|
|
|
|
field tx_id coinpayments_transaction.id cascade
|
|
|
|
// state is one of cancelled or completed.
|
|
|
|
field state int ( updatable )
|
2023-01-06 16:27:42 +00:00
|
|
|
|
2023-02-23 15:35:55 +00:00
|
|
|
field created_at timestamp ( autoinsert )
|
2023-01-06 16:27:42 +00:00
|
|
|
)
|
|
|
|
|
2023-02-23 15:35:55 +00:00
|
|
|
// stripecoinpayments_invoice_project_record contains information about invoices for a project.
|
2023-01-06 16:27:42 +00:00
|
|
|
model stripecoinpayments_invoice_project_record (
|
2023-02-23 15:35:55 +00:00
|
|
|
key id
|
|
|
|
|
|
|
|
unique project_id period_start period_end
|
|
|
|
|
|
|
|
// id is UUID for this record.
|
|
|
|
field id blob
|
|
|
|
// project_id refers to projects.id.
|
|
|
|
field project_id blob
|
|
|
|
// storage is the bytes*hour that are billed.
|
|
|
|
field storage float64
|
|
|
|
// egress is the amount of bytes for the billing period.
|
|
|
|
field egress int64
|
|
|
|
// objects is the count of objects for the billing period.
|
|
|
|
field objects int64 ( nullable )
|
|
|
|
// segments is the count of segments for the billing period.
|
|
|
|
field segments int64 ( nullable )
|
|
|
|
// period_start is the starting time the invoice covers.
|
|
|
|
field period_start timestamp
|
|
|
|
// period_end is the ending time the invoice covers.
|
|
|
|
field period_end timestamp
|
|
|
|
// state = 0 indicates that the record has not been applied yet.
|
|
|
|
field state int ( updatable )
|
|
|
|
|
|
|
|
// created_at is the time this record was added.
|
|
|
|
field created_at timestamp ( autoinsert )
|
2023-01-06 16:27:42 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
create stripecoinpayments_invoice_project_record ()
|
|
|
|
update stripecoinpayments_invoice_project_record (
|
2023-02-23 15:35:55 +00:00
|
|
|
where stripecoinpayments_invoice_project_record.id = ?
|
2023-01-06 16:27:42 +00:00
|
|
|
)
|
|
|
|
read one (
|
2023-02-23 15:35:55 +00:00
|
|
|
select stripecoinpayments_invoice_project_record
|
|
|
|
where stripecoinpayments_invoice_project_record.project_id = ?
|
|
|
|
where stripecoinpayments_invoice_project_record.period_start = ?
|
|
|
|
where stripecoinpayments_invoice_project_record.period_end = ?
|
2023-01-06 16:27:42 +00:00
|
|
|
)
|
|
|
|
read limitoffset (
|
2023-02-23 15:35:55 +00:00
|
|
|
select stripecoinpayments_invoice_project_record
|
|
|
|
where stripecoinpayments_invoice_project_record.period_start = ?
|
|
|
|
where stripecoinpayments_invoice_project_record.period_end = ?
|
|
|
|
where stripecoinpayments_invoice_project_record.state = ?
|
2023-01-06 16:27:42 +00:00
|
|
|
)
|
|
|
|
|
2023-02-23 15:35:55 +00:00
|
|
|
// stripecoinpayments_tx_conversion_rate contains information about a conversion-rate that was used in a transaction.
|
2023-01-06 16:27:42 +00:00
|
|
|
model stripecoinpayments_tx_conversion_rate (
|
2023-02-23 15:35:55 +00:00
|
|
|
key tx_id
|
2023-01-06 16:27:42 +00:00
|
|
|
|
2023-02-23 15:35:55 +00:00
|
|
|
// tx_id refers to coinpayments transaction id.
|
|
|
|
field tx_id text
|
|
|
|
// rate_numeric is the conversion rate.
|
|
|
|
field rate_numeric float64
|
2023-01-06 16:27:42 +00:00
|
|
|
|
2023-02-23 15:35:55 +00:00
|
|
|
// created_at is the time this conversion rate was added.
|
|
|
|
field created_at timestamp ( autoinsert )
|
2023-01-06 16:27:42 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
create stripecoinpayments_tx_conversion_rate ()
|
|
|
|
|
|
|
|
read one (
|
2023-02-23 15:35:55 +00:00
|
|
|
select stripecoinpayments_tx_conversion_rate
|
|
|
|
where stripecoinpayments_tx_conversion_rate.tx_id = ?
|
2023-01-06 16:27:42 +00:00
|
|
|
)
|
|
|
|
|
2023-02-23 15:35:55 +00:00
|
|
|
// storjscan_payment contains information about payments from storjscan.
|
2023-01-06 16:27:42 +00:00
|
|
|
model storjscan_payment (
|
2023-02-23 15:35:55 +00:00
|
|
|
key block_hash log_index
|
|
|
|
|
|
|
|
index (fields block_number log_index)
|
|
|
|
|
|
|
|
// block_hash is the ethereum block hash where this transfer appeared in.
|
|
|
|
field block_hash blob
|
|
|
|
// block_number is the ethereum block number where this transfer appeared in.
|
|
|
|
field block_number int64
|
|
|
|
// transaction is the ethereum transaction hash.
|
|
|
|
field transaction blob
|
|
|
|
// log_index is used for deduplicating multiple events.
|
|
|
|
field log_index int
|
|
|
|
// from_address is the source account for the transfer.
|
|
|
|
field from_address blob
|
|
|
|
// to_address is the destination account for the transfer.
|
|
|
|
field to_address blob
|
|
|
|
// token_value is the amount in tokens.
|
|
|
|
field token_value int64
|
|
|
|
// usd_value is the converted USD amount.
|
|
|
|
field usd_value int64
|
|
|
|
// status refers to payments.Status, which is one of "pending" or "confirmed".
|
|
|
|
field status text
|
|
|
|
// timestamp refers to when the payment happened.
|
|
|
|
field timestamp timestamp
|
|
|
|
// created_at refers to when the payment was added to the table.
|
|
|
|
field created_at timestamp ( autoinsert )
|
2023-01-06 16:27:42 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
create storjscan_payment (
|
2023-02-23 15:35:55 +00:00
|
|
|
noreturn
|
2023-01-06 16:27:42 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
read all (
|
2023-02-23 15:35:55 +00:00
|
|
|
select storjscan_payment
|
|
|
|
orderby ( asc storjscan_payment.block_number, asc storjscan_payment.log_index )
|
2023-01-06 16:27:42 +00:00
|
|
|
)
|
|
|
|
read limitoffset (
|
2023-02-23 15:35:55 +00:00
|
|
|
select storjscan_payment
|
|
|
|
where storjscan_payment.to_address = ?
|
|
|
|
orderby ( desc storjscan_payment.block_number, desc storjscan_payment.log_index )
|
2023-01-06 16:27:42 +00:00
|
|
|
)
|
|
|
|
read first (
|
2023-02-23 15:35:55 +00:00
|
|
|
select storjscan_payment.block_number
|
|
|
|
where storjscan_payment.status = ?
|
|
|
|
orderby ( desc storjscan_payment.block_number, desc storjscan_payment.log_index )
|
2023-01-06 16:27:42 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
delete storjscan_payment (
|
2023-02-23 15:35:55 +00:00
|
|
|
where storjscan_payment.status = ?
|
2023-01-06 16:27:42 +00:00
|
|
|
)
|