Created
April 7, 2021 00:42
-
-
Save gaurangrshah/cd6c0af014c499ff65c06ba40cf6115b to your computer and use it in GitHub Desktop.
sql snippets used for supabase
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- inserts a row into public.users | |
create function public.handle_new_user() | |
returns trigger as $$ | |
begin | |
insert into public.users (id) | |
values (new.id); | |
return new; | |
end; | |
$$ language plpgsql security definer; | |
-- 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_user(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create table users ( | |
id uuid references auth.users not null primary key, | |
email text | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment