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