Skip to content

Commit

Permalink
Added a notification for action_definition_inserted
Browse files Browse the repository at this point in the history
  • Loading branch information
cohansen committed Mar 4, 2025
1 parent 0d8fc06 commit 0e273a1
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
2 changes: 2 additions & 0 deletions deployment/hasura/migrations/Aerie/14_actions/down.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ drop function actions.notify_action_run_inserted cascade;

drop table actions.action_run cascade;

drop trigger notify_action_definition_inserted on actions.action_definition;
drop function actions.notify_action_definition_inserted cascade;
drop trigger set_timestamp on actions.action_definition;
drop table actions.action_definition cascade;

Expand Down
25 changes: 25 additions & 0 deletions deployment/hasura/migrations/Aerie/14_actions/up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,31 @@ create trigger set_timestamp
for each row
execute function util_functions.set_updated_at();

create function actions.notify_action_definition_inserted()
returns trigger
security definer
language plpgsql as $$
begin
perform (
with payload(action_definition_id,
action_file_path) as
(
select NEW.id,
uf.name
from merlin.uploaded_file uf
where uf.id = NEW.action_file_id
)
select pg_notify('action_definition_inserted', json_strip_nulls(row_to_json(payload))::text)
from payload
);
return null;
end$$;

create trigger notify_action_definition_inserted
after insert on actions.action_definition
for each row
execute function actions.notify_action_definition_inserted();

create table actions.action_run (
id integer generated always as identity,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,28 @@ create trigger set_timestamp
before update on actions.action_definition
for each row
execute function util_functions.set_updated_at();

create function actions.notify_action_definition_inserted()
returns trigger
security definer
language plpgsql as $$
begin
perform (
with payload(action_definition_id,
action_file_path) as
(
select NEW.id,
uf.name
from merlin.uploaded_file uf
where uf.id = NEW.action_file_id
)
select pg_notify('action_definition_inserted', json_strip_nulls(row_to_json(payload))::text)
from payload
);
return null;
end$$;

create trigger notify_action_definition_inserted
after insert on actions.action_definition
for each row
execute function actions.notify_action_definition_inserted();

0 comments on commit 0e273a1

Please sign in to comment.