Skip to content

Commit

Permalink
disable triggers rather than drop
Browse files Browse the repository at this point in the history
  • Loading branch information
itsakifa committed Jun 20, 2024
1 parent d092234 commit e91d219
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 22 deletions.
6 changes: 3 additions & 3 deletions datamodel/changelogs/0101/0101_1_drop_trigger.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- Trigger in signalo_db.sign before changes
DROP TRIGGER IF EXISTS tr_sign_on_delete_reorder ON signalo_db.sign;
DROP TRIGGER IF EXISTS tr_sign_on_update_prevent_fk_frame ON signalo_db.sign;
--Disable triggers in signalo_db.sign before changes
ALTER TABLE signalo_db.sign DISABLE TRIGGER ALL;

DROP FUNCTION IF EXISTS signalo_db.ft_reorder_signs_in_frame();
DROP FUNCTION IF EXISTS signalo_db.ft_sign_prevent_fk_frame_update();
21 changes: 2 additions & 19 deletions datamodel/changelogs/0101/0101_2_balises.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
--Add to signalo_db.sign a field named fk_balise
--Disable foreign keys
ALTER TABLE signalo_db.sign
DROP CONSTRAINT fkey_vl_marker_type;

Expand Down Expand Up @@ -137,21 +137,4 @@ $BODY$;
ALTER FUNCTION signalo_db.ft_sign_prevent_fk_frame_update()
OWNER TO postgres;


-- Set trigger: tr_sign_on_delete_reorder
CREATE OR REPLACE TRIGGER tr_sign_on_delete_reorder
AFTER DELETE
ON signalo_db.sign
FOR EACH ROW
EXECUTE FUNCTION signalo_db.ft_reorder_signs_in_frame();

COMMENT ON TRIGGER tr_sign_on_delete_reorder ON signalo_db.sign
IS 'Trigger: update signs order after deleting one.';

-- Set trigger: tr_sign_on_update_prevent_fk_frame
CREATE OR REPLACE TRIGGER tr_sign_on_update_prevent_fk_frame
BEFORE UPDATE OF fk_frame
ON signalo_db.sign
FOR EACH ROW
WHEN (new.fk_frame <> old.fk_frame)
EXECUTE FUNCTION signalo_db.ft_sign_prevent_fk_frame_update();
ALTER TABLE signalo_db.sign ENABLE TRIGGER ALL;

0 comments on commit e91d219

Please sign in to comment.