-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
db4adb4
commit caf2f4a
Showing
6 changed files
with
83 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1 @@ | ||
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(); | ||
-- Empty |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
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; |
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,23 @@ | ||
DO $$ | ||
DECLARE | ||
table_name TEXT; | ||
BEGIN | ||
FOR table_name IN | ||
SELECT t.table_name | ||
FROM information_schema.tables t | ||
WHERE t.table_schema = current_schema() AND t.table_type = 'BASE TABLE' | ||
AND t.table_name IN ( | ||
'canaries', | ||
'checks', | ||
'check_statuses' | ||
) | ||
LOOP | ||
EXECUTE format(' | ||
CREATE OR REPLACE TRIGGER %I_reset_is_pushed_before_update | ||
BEFORE UPDATE ON %I | ||
FOR EACH ROW | ||
EXECUTE PROCEDURE reset_is_pushed_before_update()', | ||
table_name, table_name | ||
); | ||
END LOOP; | ||
END $$; |
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,24 @@ | ||
DO $$ | ||
DECLARE | ||
table_name TEXT; | ||
BEGIN | ||
FOR table_name IN | ||
SELECT t.table_name | ||
FROM information_schema.tables t | ||
WHERE t.table_schema = current_schema() AND t.table_type = 'BASE TABLE' | ||
AND t.table_name IN ( | ||
'config_scrapers', | ||
'config_items', | ||
'config_changes', | ||
'config_analysis' | ||
) | ||
LOOP | ||
EXECUTE format(' | ||
CREATE OR REPLACE TRIGGER %I_reset_is_pushed_before_update | ||
BEFORE UPDATE ON %I | ||
FOR EACH ROW | ||
EXECUTE PROCEDURE reset_is_pushed_before_update()', | ||
table_name, table_name | ||
); | ||
END LOOP; | ||
END $$; |
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,22 @@ | ||
DO $$ | ||
DECLARE | ||
table_name TEXT; | ||
BEGIN | ||
FOR table_name IN | ||
SELECT t.table_name | ||
FROM information_schema.tables t | ||
WHERE t.table_schema = current_schema() AND t.table_type = 'BASE TABLE' | ||
AND t.table_name IN ( | ||
'topologies' | ||
'components' | ||
) | ||
LOOP | ||
EXECUTE format(' | ||
CREATE OR REPLACE TRIGGER %I_reset_is_pushed_before_update | ||
BEFORE UPDATE ON %I | ||
FOR EACH ROW | ||
EXECUTE PROCEDURE reset_is_pushed_before_update()', | ||
table_name, table_name | ||
); | ||
END LOOP; | ||
END $$; |