-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BCF-2880 remove unused db funcs and triggers (#11730)
- Loading branch information
1 parent
e8c68bd
commit c1eeb28
Showing
2 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
core/store/migrate/migrations/0216_drop_terra_state_transition_trigger.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,27 @@ | ||
-- +goose Up | ||
|
||
-- +goose StatementBegin | ||
DROP FUNCTION IF EXISTS PUBLIC.check_terra_msg_state_transition; | ||
-- +goose StatementEnd | ||
|
||
-- +goose Down | ||
-- +goose StatementBegin | ||
|
||
CREATE OR REPLACE FUNCTION PUBLIC.check_terra_msg_state_transition() RETURNS TRIGGER AS $$ | ||
DECLARE | ||
state_transition_map jsonb := json_build_object( | ||
'unstarted', json_build_object('errored', true, 'started', true), | ||
'started', json_build_object('errored', true, 'broadcasted', true), | ||
'broadcasted', json_build_object('errored', true, 'confirmed', true)); | ||
BEGIN | ||
IF NOT state_transition_map ? OLD.state THEN | ||
RAISE EXCEPTION 'Invalid from state %. Valid from states %', OLD.state, state_transition_map; | ||
END IF; | ||
IF NOT state_transition_map->OLD.state ? NEW.state THEN | ||
RAISE EXCEPTION 'Invalid state transition from % to %. Valid to states %', OLD.state, NEW.state, state_transition_map->OLD.state; | ||
END IF; | ||
RETURN NEW; | ||
END | ||
$$ LANGUAGE plpgsql; | ||
|
||
-- +goose StatementEnd |
48 changes: 48 additions & 0 deletions
48
core/store/migrate/migrations/0217_drop_unused_job_triggers.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,48 @@ | ||
-- +goose Up | ||
-- +goose StatementBegin | ||
DROP TRIGGER IF EXISTS notify_job_created ON PUBLIC.jobs; | ||
DROP FUNCTION IF EXISTS PUBLIC.notifyjobcreated(); | ||
|
||
DROP TRIGGER IF EXISTS notify_job_deleted ON PUBLIC.jobs; | ||
DROP FUNCTION IF EXISTS PUBLIC.notifyjobdeleted(); | ||
|
||
DROP TRIGGER IF EXISTS notify_pipeline_run_started ON PUBLIC.pipeline_runs; | ||
DROP FUNCTION IF EXISTS PUBLIC.notifypipelinerunstarted(); | ||
-- +goose StatementEnd | ||
|
||
|
||
-- +goose Down | ||
-- +goose StatementBegin | ||
CREATE FUNCTION PUBLIC.notifyjobcreated() RETURNS trigger | ||
LANGUAGE plpgsql | ||
AS $$ | ||
BEGIN | ||
PERFORM pg_notify('insert_on_jobs', NEW.id::text); | ||
RETURN NEW; | ||
END | ||
$$; | ||
CREATE TRIGGER notify_job_created AFTER INSERT ON PUBLIC.jobs FOR EACH ROW EXECUTE PROCEDURE PUBLIC.notifyjobcreated(); | ||
|
||
CREATE FUNCTION PUBLIC.notifyjobdeleted() RETURNS trigger | ||
LANGUAGE plpgsql | ||
AS $$ | ||
BEGIN | ||
PERFORM pg_notify('delete_from_jobs', OLD.id::text); | ||
RETURN OLD; | ||
END | ||
$$; | ||
CREATE TRIGGER notify_job_deleted AFTER DELETE ON PUBLIC.jobs FOR EACH ROW EXECUTE PROCEDURE PUBLIC.notifyjobdeleted(); | ||
|
||
CREATE FUNCTION PUBLIC.notifypipelinerunstarted() RETURNS trigger | ||
LANGUAGE plpgsql | ||
AS $$ | ||
BEGIN | ||
IF NEW.finished_at IS NULL THEN | ||
PERFORM pg_notify('pipeline_run_started', NEW.id::text); | ||
END IF; | ||
RETURN NEW; | ||
END | ||
$$; | ||
CREATE TRIGGER notify_pipeline_run_started AFTER INSERT ON PUBLIC.pipeline_runs FOR EACH ROW EXECUTE PROCEDURE PUBLIC.notifypipelinerunstarted(); | ||
|
||
-- +goose StatementEnd |