treasuredb/schema/triggers/enforceImmutableTransfer.sql
2017-01-28 14:00:20 +01:00

9 lines
338 B
SQL

CREATE TRIGGER enforceImmutableTransfer
BEFORE UPDATE OF timestamp, credId, billId, amount ON Transfer -- Allow update of note
WHEN OLD.amount IS NOT NULL
AND NOT EXISTS (SELECT * FROM __INTERNAL_TRIGGER_STACK)
BEGIN
SELECT RAISE(FAIL, "Transfer cannot be updated, but needs to be replaced to make triggers run");
END;