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
sik
sik265d ago
yea currently there is no official support from supabase to get auth.users might check this issue on github
sik
sik265d 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
cygnusbass217d ago
any news on this?
Kohyh
Kohyh145d 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
Spark14d 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
More Posts
Are postgres CONSTRAINTS supported when creating a table schema?In the column builder types I see there's a general assumption of `name`, `dataType`, `columnType`. Optional/Default value for Relational `Extras`I have a couple cases where a default/optional value for "extras" in the relational query builder coimport { PostgresError } from "postgres" - build error?I'm getting build error when i try to import `PostgresError` from `postgres` It says `The requested How to do this query in one step instead of two?Is there a better way to do this than having two different queries? // gets all posts for a specifiHow to query from a many to many relationship?Hi all, I am trying to get all the posts by a user. My schema has a many-to-many relationship set Correct way to deal with MySqlRawQueryResultWhat is best practice to check if the data was created and how to get the newly added data? ``` db.Unknown option schemaFilter for drizzle-kit introspectThe documentation https://orm.drizzle.team/kit-docs/commands#introspect--pull states that there is aHow are you all seeding your database?I see a question from back in March (5 months ago -- https://discord.com/channels/104389093259398762Why it's not possible to use `where` here?I'm trying to make a PoC for drizzle and I'm converting some sequelize to Drizzle, but I don't realloptional parent child relationship on same tableHi all I have a table called 'comments' Some comments will have a parent comment, while others wilConverting drizzle custom type to Postgres composite type fails for arraysI have a postgres composite type in my database consisting of three fields, `accountNumber, beneficiCannot drop primary keyI needed to change a table from a single field PK to a composite PK, using the following syntax ```InferSelectModel vs. InferInsertModelI couldn’t find any documentation on what the differences are. My best guess is maybe the insert typparameterized insert and updateHow does one do parameterized inserts and updates? When I try and do something like this: ``` const