readitron
readitron
DTDrizzle Team
Created by readitron on 3/4/2024 in #help
How to reference supabase auth user?
I have supabase authentication login setup, so when user logs into web app, it saves to supabase's authentication table. how do i create a reference from drizzle's schema to the auth UID? i want my project table to reference the logged in user for example:
export const project = pgTable("project", {
id: uuid("id").primaryKey().notNull(),
name: text("name").notNull(),
url: text("url").notNull(),
description: text("description"),
submittedBy: uuid("id").notNull().references(() => auth.users.id, { onDelete: "cascade" }),
createdAt: timestamp("created_at", {
withTimezone: true,
})
.notNull()
.defaultNow(),
updatedAt: timestamp("updated_at", {
withTimezone: true,
})
.notNull()
.defaultNow(),
});
export const project = pgTable("project", {
id: uuid("id").primaryKey().notNull(),
name: text("name").notNull(),
url: text("url").notNull(),
description: text("description"),
submittedBy: uuid("id").notNull().references(() => auth.users.id, { onDelete: "cascade" }),
createdAt: timestamp("created_at", {
withTimezone: true,
})
.notNull()
.defaultNow(),
updatedAt: timestamp("updated_at", {
withTimezone: true,
})
.notNull()
.defaultNow(),
});
I saw something similar in another post with the references, but how do i get auth? not sure if this is the correct way still?
9 replies