Dealing with Supabase Auth

Hey guys! I set up a user schema in drizzle and linked it to the auth users in supabase

export const authSchema = pgSchema('auth')

export const authUsers = authSchema.table('users', {
  id: uuid('id').primaryKey().notNull(),
})

export const user = pgTable('user', {
  id: uuid('id')
    .primaryKey()
    .notNull()
    .references(() => authUsers.id, { onDelete: 'cascade' }),
  createdAt: timestamp('created_at').defaultNow(),
  updatedAt: timestamp('updated_at'),
  name: text('name').notNull(),
})


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!
Was this page helpful?