Reference to auth.users?

i was following ben davis video about sveltekit + supabase/drizzle. in his video he mention that he want to use sql file in supabase/migrations as a source of truth and then rewrote it in schema.ts,
create table profile (
id serial primary key,
first_name varchar(100),
last_name varchar(100),
email varchar(100),
user_id uuid references auth.users
);
create table profile (
id serial primary key,
first_name varchar(100),
last_name varchar(100),
email varchar(100),
user_id uuid references auth.users
);
but i prefer to use schema.ts as a source of truth then use the drizzle migrations.
export const profileTable = pgTable('profile', {
id: serial('id').primaryKey(),
last_name: varchar('last_name', { length: 100 }),
first_name: varchar('first_name', { length: 100 }),
email: varchar('email', { length: 100 }),
user_id: uuid('user_id').notNull().references(() => auth.users),
});
export const profileTable = pgTable('profile', {
id: serial('id').primaryKey(),
last_name: varchar('last_name', { length: 100 }),
first_name: varchar('first_name', { length: 100 }),
email: varchar('email', { length: 100 }),
user_id: uuid('user_id').notNull().references(() => auth.users),
});
the problem is that i can't reference the auth.users like in the .sql file
5 Replies
sik
sik15mo ago
yea currently there is no official support from supabase to get auth.users might check this issue on github
sik
sik15mo ago
GitHub
Add ability to (read-only) query the auth.users table directly with...
Feature request I suggest adding the ability to query (read-only) the auth.users table directly with a service key. Many production apps need this ability... Describe the solution you'd like //...
cygnusbass
cygnusbass14mo ago
any news on this?
Kohyh
Kohyh11mo ago
any work around or whats the current way of working with supabase auth with drizzle orm? sorry newbie here also running into the exact same problem
Spark
Spark7mo ago
I just manually added the foreign key from public.profile id -> auth.users id and followed this https://supabase.com/docs/guides/auth/managing-user-data#using-triggers
Supabase
Managing User Data | Supabase Docs
Securing your user data with Row Level Security.
Want results from more Discord servers?
Add your server