treasuredb/schema/triggers/enforceSpentImmutableOutsideTrigger.sql

10 lines
395 B
MySQL
Raw Normal View History

-- Prevent modification of spent value outside triggers which must adjust it exclusively
-- when new transfer records are inserted
CREATE TRIGGER enforceSpentImmutableOutsideTrigger
BEFORE UPDATE OF spent ON Credit
2017-01-22 21:20:17 +01:00
WHEN NOT EXISTS (SELECT * FROM __INTERNAL_TRIGGER_STACK)
BEGIN
2017-01-22 21:20:17 +01:00
SELECT RAISE(FAIL, "spent is set and adjusted automatically according to added Transfer records");
END;