14 lines
919 B
MySQL
14 lines
919 B
MySQL
|
|
-- Migration: Add refund/honest-accounting columns to jobs table
|
||
|
|
-- Users are refunded the overpayment (work invoice amount - actual cost) after job completion.
|
||
|
|
|
||
|
|
ALTER TABLE jobs
|
||
|
|
ADD COLUMN IF NOT EXISTS actual_amount_sats INTEGER,
|
||
|
|
ADD COLUMN IF NOT EXISTS refund_amount_sats INTEGER,
|
||
|
|
ADD COLUMN IF NOT EXISTS refund_state TEXT,
|
||
|
|
ADD COLUMN IF NOT EXISTS refund_payment_hash TEXT;
|
||
|
|
|
||
|
|
COMMENT ON COLUMN jobs.actual_amount_sats IS 'Actual charge in sats (raw token cost + DO infra + margin), computed post-execution using the locked BTC price';
|
||
|
|
COMMENT ON COLUMN jobs.refund_amount_sats IS 'Overpayment in sats to return to the user (work_amount_sats - actual_amount_sats, clamped >= 0)';
|
||
|
|
COMMENT ON COLUMN jobs.refund_state IS 'Refund lifecycle: not_applicable | pending | paid';
|
||
|
|
COMMENT ON COLUMN jobs.refund_payment_hash IS 'Payment hash of the outgoing Lightning refund payment once sent';
|