-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* remove silented errors when insert in synthese * add migration for trigger delete in synthese --------- Co-authored-by: amandine-sahl <[email protected]>
- Loading branch information
1 parent
f1a2616
commit ae4ebc8
Showing
3 changed files
with
73 additions
and
57 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
backend/gn_module_monitoring/migrations/7fbcdd93626a_trigger_monitoring.py
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,66 @@ | ||
"""trigger drop synthese monitoring | ||
Revision ID: 7fbcdd93626a | ||
Revises: f3413cccdfa8 | ||
Create Date: 2024-01-11 17:25:05.135068 | ||
""" | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = "7fbcdd93626a" | ||
down_revision = "f3413cccdfa8" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
op.execute( | ||
""" | ||
DROP TRIGGER IF EXISTS trg_delete_synthese_observations ON gn_monitoring.t_observations; | ||
DROP FUNCTION IF EXISTS gn_synthese.fct_trg_delete_synthese_observations(); | ||
CREATE FUNCTION gn_synthese.fct_trg_delete_synthese_observations() RETURNS trigger AS $$ | ||
BEGIN | ||
--Suppression des données dans la synthèse | ||
DELETE FROM gn_synthese.synthese WHERE unique_id_sinp = OLD.uuid_observation; | ||
RETURN OLD; | ||
END; | ||
$$ LANGUAGE plpgsql; | ||
CREATE TRIGGER trg_delete_synthese_observations AFTER DELETE ON gn_monitoring.t_observations | ||
FOR EACH ROW EXECUTE PROCEDURE gn_synthese.fct_trg_delete_synthese_observations(); | ||
DROP TRIGGER IF EXISTS trg_delete_synthese_visits ON gn_monitoring.t_base_visits; | ||
DROP FUNCTION IF EXISTS gn_synthese.fct_trg_delete_synthese_visits() CASCADE; | ||
CREATE FUNCTION gn_synthese.fct_trg_delete_synthese_visits() RETURNS trigger AS $$ | ||
BEGIN | ||
--Suppression des données dans la synthèse | ||
DELETE FROM gn_synthese.synthese WHERE unique_id_sinp = OLD.uuid_base_visit; | ||
RETURN OLD; | ||
END; | ||
$$ LANGUAGE plpgsql; | ||
CREATE TRIGGER trg_delete_synthese_visits AFTER DELETE ON gn_monitoring.t_base_visits | ||
FOR EACH ROW EXECUTE PROCEDURE gn_synthese.fct_trg_delete_synthese_visits(); | ||
""" | ||
) | ||
|
||
|
||
def downgrade(): | ||
op.execute( | ||
""" | ||
DROP TRIGGER trg_delete_synthese_observations ON gn_monitoring.t_observations; | ||
DROP FUNCTION gn_synthese.fct_trg_delete_synthese_observations(); | ||
DROP TRIGGER trg_delete_synthese_visits ON gn_monitoring.t_base_visits; | ||
DROP FUNCTION gn_synthese.fct_trg_delete_synthese_visits(); | ||
""" | ||
) |
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 was deleted.
Oops, something went wrong.