changeset 597:0963afafaa07 find-refactoring

make all trigger creations idempotent
author Alain Mazy <am@orthanc.team>
date Wed, 27 Nov 2024 13:05:10 +0100
parents 28c9b3e5b3ad
children 8f6e7ae942f3
files PostgreSQL/Plugins/SQL/PrepareIndex.sql
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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