Some rewording and language fixes in schema.sql

This commit is contained in:
Florian "flowdy" Heß 2016-06-05 20:00:30 +02:00
parent 3c483d60e6
commit b8a8d9c935

View File

@ -69,7 +69,7 @@ BEGIN
UPDATE Debit UPDATE Debit
SET paid = paid + CASE SET paid = paid + CASE
WHEN (SELECT d FROM _temp) <= 0 WHEN (SELECT d FROM _temp) <= 0
THEN RAISE(FAIL, "Debt is already paid") THEN RAISE(FAIL, "Debt settled")
ELSE ELSE
(SELECT m FROM _temp) (SELECT m FROM _temp)
END END
@ -86,7 +86,7 @@ BEGIN
UPDATE Credit UPDATE Credit
SET spent = spent + CASE SET spent = spent + CASE
WHEN (SELECT c FROM _temp) <= 0 WHEN (SELECT c FROM _temp) <= 0
THEN RAISE(FAIL, "Credit is already spent") THEN RAISE(FAIL, "Credit spent")
ELSE ELSE
(SELECT m FROM _temp) (SELECT m FROM _temp)
END END
@ -132,17 +132,17 @@ CREATE TRIGGER enforceImmutableTransfer
BEFORE UPDATE ON Transfer BEFORE UPDATE ON Transfer
WHEN OLD.amount IS NOT NULL WHEN OLD.amount IS NOT NULL
BEGIN BEGIN
SELECT RAISE(FAIL, "Transfer cannot be updated, but needs to be revoked and re-inserted to ensure the triggers run"); SELECT RAISE(FAIL, "Transfer cannot be updated, but needs to be revoked and re-inserted to run triggers");
END; END;
CREATE TRIGGER enforceiZeroPaidAtStart CREATE TRIGGER enforceiZeroPaidAtStart
BEFORE INSERT ON Debit BEFORE INSERT ON Debit
BEGIN BEGIN
SELECT RAISE(FAIL, "debt must be initially unpaid") SELECT RAISE(FAIL, "Debt must be initially unpaid")
WHERE NEW.paid <> 0; WHERE NEW.paid <> 0;
END; END;
-- Prevent modification with paid value outside triggers which must adjust it exclusively -- Prevent modification of paid value outside triggers which must adjust it exclusively
-- when new transfer records are inserted -- when new transfer records are inserted
CREATE TRIGGER enforceDebtImmutableOutsideTrigger CREATE TRIGGER enforceDebtImmutableOutsideTrigger
BEFORE UPDATE OF paid ON Debit BEFORE UPDATE OF paid ON Debit