Dealing with Supabase Auth
Hey guys! I set up a user schema in drizzle and linked it to the auth users in supabase
I edited the migration files to make sure it doesn't return error since auth exists. But I don't understand how auth workflow is suppossed to work. Currently I can create a user with supabase, what I imagine is that I am supposed to link them somehow so that I can then first create user in supabase then continue to create user in user table.
But then how do I deal with sign-in's and other stuff. I need to store much more information about the user.
Like for example I need to store certain roles about the user, if I log in with supabase then how am I supposed to access the details from drizzle.
Any help would be much appreciated, and thanks in advance!
4 Replies
use a trigger to create user table entries on auth table entry creation
Hey thank you for your relpy, I did just that and I understand things a lot more thank you.
But I have a small issue, I am working with local supabase, and the sql editor does not save queries, furthermore when I link my local project to my live environment will it apply my functions and triggers there too, or do I have to rewrite them there?
you need to create your functions and triggers through a supabase migration that you can then apply in production
here's an example of what I use https://gist.github.com/fnimick/37269e61f4e2374290b76554d8f994ab
Gist
Create a
public.profile
table and keep it in sync with supabase `...Create a
public.profile
table and keep it in sync with supabase auth.users
for selected fields in both directions. - supabase_profile_sync.sql