From aadad0885966f86e364ee00141929187390a3672 Mon Sep 17 00:00:00 2001
From: Sonia Zorba <sonia.zorba@inaf.it>
Date: Fri, 10 Sep 2021 12:22:11 +0200
Subject: [PATCH] Removed job_insert trigger (fields update on INSERT is now
 handled by DAO business logic)

---
 03-other-functions.sql | 19 -------------------
 1 file changed, 19 deletions(-)

diff --git a/03-other-functions.sql b/03-other-functions.sql
index e3ba587..fb75912 100644
--- a/03-other-functions.sql
+++ b/03-other-functions.sql
@@ -73,20 +73,6 @@ $func$ LANGUAGE sql;
 -- Trigger function that automatically updates start time and end time of jobs at phase update.
 -- This could be performed by business logic of each application that handles jobs but relying directly on the database ensures a better uniformity.
 
-CREATE OR REPLACE FUNCTION job_phase_inserted() RETURNS TRIGGER 
-AS 
-$func$
-BEGIN
-    IF new.phase = 'EXECUTING' THEN
-        new.start_time := NOW();
-    ELSIF new.phase = 'COMPLETED' OR new.phase = 'ERROR' THEN
-        new.start_time := NOW();
-        new.end_time := NOW();
-    END IF;
-    RETURN new;
-END;
-$func$ LANGUAGE plpgsql;
-
 CREATE OR REPLACE FUNCTION job_phase_updated() RETURNS TRIGGER 
 AS 
 $func$
@@ -102,11 +88,6 @@ BEGIN
 END;
 $func$ LANGUAGE plpgsql;
 
-CREATE TRIGGER job_insert
-    BEFORE INSERT ON job
-    FOR EACH ROW
-    EXECUTE PROCEDURE job_phase_inserted();
-
 CREATE TRIGGER job_update
     BEFORE UPDATE OF phase ON job
     FOR EACH ROW
-- 
GitLab