feat(DB): changed integrations trigger
This commit is contained in:
parent
218b0d9299
commit
1935988433
2 changed files with 17 additions and 1 deletions
|
|
@ -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;
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue