-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make targetEdit work like observationEdit
- Loading branch information
Showing
5 changed files
with
113 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
modules/service/src/main/resources/db/migration/V0924__target_update.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
CREATE OR REPLACE FUNCTION ch_target_edit() | ||
RETURNS trigger AS $$ | ||
DECLARE | ||
BEGIN | ||
IF (TG_OP = 'DELETE') THEN | ||
PERFORM pg_notify('ch_target_edit', OLD.c_target_id || ',' || OLD.c_program_id || ',' || TG_OP); | ||
END IF; | ||
IF (TG_OP = 'INSERT' OR TG_OP = 'UPDATE') THEN | ||
PERFORM pg_notify('ch_target_edit', NEW.c_target_id || ',' || NEW.c_program_id || ',' || TG_OP); | ||
END IF; | ||
RETURN NEW; | ||
END; | ||
$$ LANGUAGE plpgsql; | ||
|
||
DROP TRIGGER IF EXISTS ch_target_insert_update_trigger on t_target; | ||
|
||
CREATE CONSTRAINT TRIGGER ch_target_insert_update_trigger | ||
AFTER INSERT OR UPDATE OR DELETE ON t_target | ||
DEFERRABLE | ||
FOR EACH ROW | ||
EXECUTE PROCEDURE ch_target_edit(); | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters