Add trigger to allow update of notes as well on contact_settings.

This commit is contained in:
Bradley M. Kuhn 2022-11-21 11:39:23 -08:00
parent deb31e9c18
commit 225eb13674

View file

@ -378,6 +378,23 @@ CREATE VIEW UserOperation_contact_setting_change AS
LEFT JOIN request_type rt ON rt.id = rr.request_type_id LEFT JOIN request_type rt ON rt.id = rr.request_type_id
ORDER BY dd.ledger_entity_id, rr.date_requested; ORDER BY dd.ledger_entity_id, rr.date_requested;
DROP TRIGGER IF EXISTS contact_setting_note_updater;
CREATE TRIGGER contact_setting_note_updater
INSTEAD OF UPDATE OF note on UserOperation_contact_setting_change
BEGIN
SELECT CASE
WHEN ( OLD.setting_requested IS NULL )
THEN RAISE(FAIL, "Invalid note setting; Cannot write note on when setting_requested is NULL")
END;
UPDATE request
SET notes = NEW.note
WHERE id = OLD.request_id
AND OLD.request_id is NOT NULL
AND OLD.donor_id = donor_id
AND request_type_id = 12;
END;
DROP TRIGGER IF EXISTS contact_setting_config_change_updater; DROP TRIGGER IF EXISTS contact_setting_config_change_updater;
CREATE TRIGGER contact_setting_config_change_updater CREATE TRIGGER contact_setting_config_change_updater
INSTEAD OF UPDATE OF setting_requested on UserOperation_contact_setting_change INSTEAD OF UPDATE OF setting_requested on UserOperation_contact_setting_change