Skip to content

Commit d25fbbc

Browse files
plohaniammarkps
andauthored
feat: testcase sync migration (#866)
Co-authored-by: Possawat Suksai <[email protected]>
1 parent ad8b7cc commit d25fbbc

File tree

1 file changed

+25
-0
lines changed
  • prisma/migrations/20230708000037_add_trigger_for_testcase_sync

1 file changed

+25
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
ALTER TYPE "SyncStatus" ADD VALUE 'DELETE';
2+
3+
CREATE OR REPLACE FUNCTION public.notify_task_sync()
4+
RETURNS trigger
5+
LANGUAGE plpgsql
6+
AS $function$
7+
declare
8+
task_id text;
9+
begin
10+
task_id := new.task_id;
11+
if new.sync_status = 'PENDING' or new.sync_status = 'DELETE' then
12+
perform pg_notify('testcase_sync', task_id);
13+
end if;
14+
return new;
15+
END;
16+
$function$
17+
;
18+
19+
20+
CREATE TRIGGER create_new_task AFTER
21+
INSERT
22+
OR
23+
UPDATE
24+
ON
25+
public.testcase_sync_status for each ROW EXECUTE FUNCTION notify_task_sync();

0 commit comments

Comments
 (0)