diff --git a/scripts/helm/db/init_dbs/postgresql/1.8.2/1.8.2.sql b/scripts/helm/db/init_dbs/postgresql/1.8.2/1.8.2.sql index 6332a2b52..2671593ae 100644 --- a/scripts/helm/db/init_dbs/postgresql/1.8.2/1.8.2.sql +++ b/scripts/helm/db/init_dbs/postgresql/1.8.2/1.8.2.sql @@ -46,4 +46,18 @@ UPDATE dashboard_widgets SET config=config || '{"col":4}' WHERE metric_id IN (SELECT metric_id FROM metrics WHERE metric_type = 'funnel'); +CREATE OR REPLACE FUNCTION notify_integration() RETURNS trigger AS +$$ +BEGIN + IF NEW IS NULL THEN + PERFORM pg_notify('integration', + jsonb_build_object('project_id', OLD.project_id, 'provider', OLD.provider, 'options', + null)::text); + ELSIF (OLD IS NULL) OR (OLD.options <> NEW.options) THEN + PERFORM pg_notify('integration', row_to_json(NEW)::text); + END IF; + RETURN NULL; +END; +$$ LANGUAGE plpgsql; + COMMIT; \ No newline at end of file diff --git a/scripts/helm/db/init_dbs/postgresql/init_schema.sql b/scripts/helm/db/init_dbs/postgresql/init_schema.sql index 9fe80c718..645696eeb 100644 --- a/scripts/helm/db/init_dbs/postgresql/init_schema.sql +++ b/scripts/helm/db/init_dbs/postgresql/init_schema.sql @@ -60,7 +60,9 @@ CREATE OR REPLACE FUNCTION notify_integration() RETURNS trigger AS $$ BEGIN IF NEW IS NULL THEN - PERFORM pg_notify('integration', (row_to_json(OLD)::text || '{"options": null, "request_data": null}'::text)); + PERFORM pg_notify('integration', + jsonb_build_object('project_id', OLD.project_id, 'provider', OLD.provider, 'options', + null)::text); ELSIF (OLD IS NULL) OR (OLD.options <> NEW.options) THEN PERFORM pg_notify('integration', row_to_json(NEW)::text); END IF;