diff options
Diffstat (limited to 'src/backenddb/merchant-0001.sql')
-rw-r--r-- | src/backenddb/merchant-0001.sql | 50 |
1 files changed, 38 insertions, 12 deletions
diff --git a/src/backenddb/merchant-0001.sql b/src/backenddb/merchant-0001.sql index 4e2b0639..d6b25d8d 100644 --- a/src/backenddb/merchant-0001.sql +++ b/src/backenddb/merchant-0001.sql @@ -383,35 +383,61 @@ CREATE INDEX IF NOT EXISTS merchant_contract_terms_by_merchant_session_and_fulfi ---------------- Payment and refunds --------------------------- -CREATE TABLE IF NOT EXISTS merchant_deposits - (deposit_serial BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY +CREATE TABLE IF NOT EXISTS merchant_deposit_confirmations + (deposit_confirmation_serial BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY ,order_serial BIGINT REFERENCES merchant_contract_terms (order_serial) ON DELETE CASCADE ,deposit_timestamp INT8 NOT NULL - ,coin_pub BYTEA NOT NULL CHECK (LENGTH(coin_pub)=32) ,exchange_url TEXT NOT NULL - ,amount_with_fee taler_amount_currency NOT NULL - ,deposit_fee taler_amount_currency NOT NULL - ,refund_fee taler_amount_currency NOT NULL + ,total_without_fee taler_amount_currency NOT NULL ,wire_fee taler_amount_currency NOT NULL ,signkey_serial BIGINT NOT NULL REFERENCES merchant_exchange_signing_keys (signkey_serial) ON DELETE CASCADE ,exchange_sig BYTEA NOT NULL CHECK (LENGTH(exchange_sig)=64) ,account_serial BIGINT NOT NULL REFERENCES merchant_accounts (account_serial) ON DELETE CASCADE - ,UNIQUE (order_serial, coin_pub) + ,UNIQUE (order_serial, exchange_sig) ); -COMMENT ON TABLE merchant_deposits +COMMENT ON TABLE merchant_deposit_confirmations IS 'Table with the deposit confirmations for each coin we deposited at the exchange'; -COMMENT ON COLUMN merchant_deposits.signkey_serial +COMMENT ON COLUMN merchant_deposit_confirmations.signkey_serial IS 'Online signing key of the exchange on the deposit confirmation'; -COMMENT ON COLUMN merchant_deposits.deposit_timestamp +COMMENT ON COLUMN merchant_deposit_confirmations.deposit_timestamp IS 'Time when the exchange generated the deposit confirmation'; -COMMENT ON COLUMN merchant_deposits.exchange_sig +COMMENT ON COLUMN merchant_deposit_confirmations.exchange_sig IS 'Signature of the exchange over the deposit confirmation'; -COMMENT ON COLUMN merchant_deposits.wire_fee +COMMENT ON COLUMN merchant_deposit_confirmations.wire_fee IS 'We MAY want to see if we should try to get this via merchant_exchange_wire_fees (not sure, may be too complicated with the date range, etc.)'; + +CREATE TABLE IF NOT EXISTS merchant_deposits + (deposit_serial BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY + ,coin_offset INT4 NOT NULL + ,deposit_confirmation_serial BIGINT NOT NULL + REFERENCES merchant_deposit_confirmations (deposit_confirmation_serial) ON DELETE CASCADE + ,coin_pub BYTEA NOT NULL CHECK (LENGTH(coin_pub)=32) + ,coin_sig BYTEA NOT NULL CHECK (LENGTH(coin_sig)=64) + ,amount_with_fee taler_amount_currency NOT NULL + ,deposit_fee taler_amount_currency NOT NULL + ,refund_fee taler_amount_currency NOT NULL + ,UNIQUE (deposit_confirmation_serial, coin_pub) + ); +COMMENT ON TABLE merchant_deposits + IS 'Table with the deposit details for each coin we deposited at the exchange'; +COMMENT ON COLUMN merchant_deposits.coin_offset + IS 'Offset of this coin in the batch'; +COMMENT ON COLUMN merchant_deposits.deposit_confirmation_serial + IS 'Reference to the deposit confirmation of the exchange'; +COMMENT ON COLUMN merchant_deposits.coin_pub + IS 'Public key of the coin that was deposited'; +COMMENT ON COLUMN merchant_deposits.amount_with_fee + IS 'Total amount (incl. fee) of the coin that was deposited'; +COMMENT ON COLUMN merchant_deposits.deposit_fee + IS 'Deposit fee (for this coin) that was paid'; +COMMENT ON COLUMN merchant_deposits.refund_fee + IS 'How high would the refund fee be (for this coin)'; + + CREATE TABLE IF NOT EXISTS merchant_refunds (refund_serial BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY ,order_serial BIGINT NOT NULL |