myheats

Live heats, scoring and leaderboard for sport events
git clone https://git.in0rdr.ch/myheats.git
Log | Files | Refs | Pull requests | README | LICENSE

commit 5019c80de2640fa4f60d492780279c53b6f8602c
parent d14f841de98fd3c2a110c7c952060d914b603dc3
Author: Andreas Gruhler <andreas.gruhler@adfinis.com>
Date:   Sun, 12 Mar 2023 22:50:10 +0100

doc: sql trigger for judges

Diffstat:
MREADME.md | 22++++++++++++++++++++++
1 file changed, 22 insertions(+), 0 deletions(-)

diff --git a/README.md b/README.md @@ -42,4 +42,26 @@ begin where s.heat = any (heat_ids); end; $$; +``` + +Add a trigger for connecting users with judges: +```sql +-- https://supabase.com/docs/guides/auth/managing-user-data#using-triggers +-- inserts a row into public.judges +create function public.handle_new_judge() +returns trigger +language plpgsql +security definer set search_path = public +as $$ +begin + insert into public.judges (id) + values (new.id); + return new; +end; +$$; + +-- trigger the function every time a user is created +create trigger on_auth_user_created + after insert on auth.users + for each row execute procedure public.handle_new_judge(); ``` \ No newline at end of file