# HG changeset patch # User Alain Mazy # Date 1732709110 -3600 # Node ID 0963afafaa07e2f5c8d849a9faf85eeb2e07810e # Parent 28c9b3e5b3ad9dba002becb0825c4948b3f3dd03 make all trigger creations idempotent diff -r 28c9b3e5b3ad -r 0963afafaa07 PostgreSQL/Plugins/SQL/PrepareIndex.sql --- a/PostgreSQL/Plugins/SQL/PrepareIndex.sql Wed Nov 27 08:52:45 2024 +0100 +++ b/PostgreSQL/Plugins/SQL/PrepareIndex.sql Wed Nov 27 13:05:10 2024 +0100 @@ -191,6 +191,7 @@ END; $body$ LANGUAGE plpgsql; +DROP TRIGGER IF EXISTS PatientAdded on Resources; CREATE TRIGGER PatientAdded AFTER INSERT ON Resources FOR EACH ROW @@ -220,6 +221,7 @@ END; $body$ LANGUAGE plpgsql; +DROP TRIGGER IF EXISTS ResourceDeleted on Resources; CREATE TRIGGER ResourceDeleted AFTER DELETE ON Resources FOR EACH ROW @@ -498,6 +500,7 @@ END; $body$ LANGUAGE plpgsql; +DROP TRIGGER IF EXISTS InsertedChange on Changes; CREATE TRIGGER InsertedChange AFTER INSERT ON Changes FOR EACH ROW @@ -678,13 +681,13 @@ END; $body$ LANGUAGE plpgsql; --- Trigger for INSERT +DROP TRIGGER IF EXISTS IncrementChildCount on Resources; CREATE TRIGGER IncrementChildCount AFTER INSERT ON Resources FOR EACH ROW EXECUTE PROCEDURE UpdateChildCount(); --- Trigger for DELETE +DROP TRIGGER IF EXISTS DecrementChildCount on Resources; CREATE TRIGGER DecrementChildCount AFTER DELETE ON Resources FOR EACH ROW