-
Notifications
You must be signed in to change notification settings - Fork 17
/
trigger.sql
32 lines (28 loc) · 844 Bytes
/
trigger.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
create or replace function fn_trigger_user_create() returns trigger
security definer
language plpgsql
as $$
begin
perform fn_project_user_create(new.uuid, new.body);
return new;
end;
$$;
create or replace function fn_trigger_user_update() returns trigger
security definer
language plpgsql
as $$
begin
perform fn_project_user_update(new.uuid, new.body);
return new;
end;
$$;
drop trigger if exists event_insert_user_create ON events;
create trigger event_insert_user_create after insert on events
for each row
when (new.type = 'user_create')
execute procedure fn_trigger_user_create();
drop trigger if exists event_insert_user_update ON events;
create trigger event_insert_user_update after insert on events
for each row
when (new.type = 'user_update')
execute procedure fn_trigger_user_update();