Marvin
04/01/2022, 8:11 AMuuid
with postgres, should I always define the db type as String
+ @db.Uuid
? I only have String
currently and I'm not sure if prisma stores the uuid as native uuid by default?Nurul
04/01/2022, 10:14 AM@id
as mentioned here in reference
Your model could look something like this:
model User {
id String @id @default(uuid())
}
Marvin
04/01/2022, 11:24 AMNurul
04/01/2022, 11:37 AMuuid()
function is implemented by prisma - UUID schema reference
You would need to use dbgenerated()
to use native UUID of PostgreSQL, here is an example of using it.Marvin
04/01/2022, 12:44 PM@db.Uuid
? I thought that's the part where the column type is specified?Nurul
04/01/2022, 1:27 PM@db.Uuid
would map the column type, in this case, it would be typed to native uuid, In the above example @db.uuid
and dbgenerated
both are used.
@default(dbgenerated("gen_random_uuid()"))
this would automatically add a PostgreSQL supported native uuid when a record is inserted.
@db.Uuid
would map the column type as native uuid.Marvin
04/01/2022, 3:14 PM