lumen
05/21/2022, 7:18 PMNeedle
05/21/2022, 7:18 PMgaryaustin
05/21/2022, 10:52 PMNeedle
05/21/2022, 10:52 PMlumen
05/21/2022, 11:15 PMprofile
rows have a foreign key to the auth.users
table?
I mean I'm not 100% sure, but isn't that how you should always connect related tables?
I'm setting things up by following a course, here's the video that says that profile
table should have a foreign key to `auth.users`:
https://egghead.io/lessons/supabase-add-relationships-between-tables-in-supabase-using-foreign-keys
(start watching at 48th second)
The video shows how to set up the foreign key using UI, but I can't do that in Prisma, since all the Prisma tables and foreign keys are defined in prisma.schema
file.
If I was creating everything in Prisma, I'd do something like:
model Profile {
id String @id @default(cuid())
// This is how I would make a foreign key in prisma,
// if the User table was defined in my schema.prisma file
user User @relation("UserProfile", fields: [userId], references: [id])
userId String
// The rest of the fields...
// [...]
}
But my User table is not defined in my prisma.schema
file, it's created by Supabase. So how do I create a foreign key from Profile to user
?
If you don't know the answer to this, since you're not a Prisma user, is there any chance you could help me find someone who does use both? I keep hearing that many people are using Prisma and Supabase, but I can't seem to find any code examples or anyone who can help me out with this.garyaustin
05/21/2022, 11:18 PMgaryaustin
05/21/2022, 11:20 PMgaryaustin
05/21/2022, 11:21 PM