create function public.handle_new_user () returns trigger as $$
declare
row_count int;
row_count_text text;
begin
-- get the current row count
-- select count(*) into row_count from profiles;
-- Increment the row count for the new username
row_count := row_count + 1;
row_count_text := row_count::text;
insert into public.profiles (id, username)
values (new.id, ('player#' || row_count_text));
return new;
end;
$$ language plpgsql security definer;
create function public.handle_new_user () returns trigger as $$
declare
row_count int;
row_count_text text;
begin
-- get the current row count
-- select count(*) into row_count from profiles;
-- Increment the row count for the new username
row_count := row_count + 1;
row_count_text := row_count::text;
insert into public.profiles (id, username)
values (new.id, ('player#' || row_count_text));
return new;
end;
$$ language plpgsql security definer;