Add the admin_cost and no-fee CHECK constraints
This commit is contained in:
1 parent
c875be4a51
commit
dd7d669a6c
1 file changed
+5
-1
+5
-1
@@ -76,7 +76,11 @@ CREATE TABLE IF NOT EXISTS transactions (
|
|||||||
CHECK (leg_in_sats IS NULL OR leg_in_ore IS NULL),
|
CHECK (leg_in_sats IS NULL OR leg_in_ore IS NULL),
|
||||||
CHECK (leg_out_sats IS NULL OR leg_out_ore IS NULL),
|
CHECK (leg_out_sats IS NULL OR leg_out_ore IS NULL),
|
||||||
CHECK (leg_in_sats IS NULL OR leg_in_sats > 0),
|
CHECK (leg_in_sats IS NULL OR leg_in_sats > 0),
|
||||||
CHECK (leg_out_sats IS NULL OR leg_out_sats > 0)
|
CHECK (leg_out_sats IS NULL OR leg_out_sats > 0),
|
||||||
|
-- admin_cost stands on its own, and two types take no fee (section 3.2).
|
||||||
|
CHECK (type = 'admin_cost' OR market_id IS NOT NULL),
|
||||||
|
CHECK (type NOT IN ('gift_received', 'admin_cost')
|
||||||
|
OR (fee_sats = 0 AND fee_ore = 0))
|
||||||
);
|
);
|
||||||
|
|
||||||
-- A lot is a quantity of sats with one acquisition date and one cost basis.
|
-- A lot is a quantity of sats with one acquisition date and one cost basis.
|
||||||
|
|||||||
Reference in new issue
Block a user