BenutzerProfil
This commit is contained in:
28
supabase/migrations/20260323010000_user_profile_deletion.sql
Normal file
28
supabase/migrations/20260323010000_user_profile_deletion.sql
Normal file
@@ -0,0 +1,28 @@
|
||||
create or replace function public.delete_current_user_profile_data()
|
||||
returns void
|
||||
language plpgsql
|
||||
security definer
|
||||
set search_path = public
|
||||
as $$
|
||||
declare
|
||||
v_user_id uuid;
|
||||
begin
|
||||
v_user_id := auth.uid();
|
||||
|
||||
if v_user_id is null then
|
||||
raise exception 'Not authenticated';
|
||||
end if;
|
||||
|
||||
delete from public.training_plans
|
||||
where user_id = v_user_id;
|
||||
|
||||
delete from public.assessments
|
||||
where user_id = v_user_id;
|
||||
|
||||
delete from public.user_profiles
|
||||
where user_id = v_user_id;
|
||||
end;
|
||||
$$;
|
||||
|
||||
revoke all on function public.delete_current_user_profile_data() from public;
|
||||
grant execute on function public.delete_current_user_profile_data() to authenticated;
|
||||
Reference in New Issue
Block a user