Skip to content

Commit

Permalink
feat: add trigger to config_analysis to reset is_pushed
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe committed Jan 2, 2024
1 parent 2ebb0c9 commit db57ef0
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions views/003_analysis_views.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
CREATE OR REPLACE FUNCTION reset_is_pushed_before_update()
RETURNS TRIGGER AS $$
BEGIN
-- If any column other than is_pushed is changed, reset is_pushed to false.
IF NEW IS DISTINCT FROM OLD AND NEW.is_pushed IS NOT DISTINCT FROM OLD.is_pushed THEN
NEW.is_pushed = false;
END IF;

RETURN NEW;
END
$$ LANGUAGE plpgsql;

CREATE OR REPLACE TRIGGER reset_is_pushed_before_update
BEFORE UPDATE ON config_analysis
FOR EACH ROW
EXECUTE PROCEDURE reset_is_pushed_before_update();

-- analysis_by_config
DROP VIEW IF EXISTS analysis_by_config;
CREATE OR REPLACE VIEW
Expand Down

0 comments on commit db57ef0

Please sign in to comment.