would like to declare a default binary value in the resulting sql migration file.
I have tried using @default(dbgenerated(“UUID_TO_BIN(uuid())”)
but the expression does not get implemented in the resulting SQL file.
would like to declare a default binary value in the resulting sql migration file.
I have tried using @default(dbgenerated(“UUID_TO_BIN(uuid())”)
but the expression does not get implemented in the resulting SQL file.
This worked for me: @default(dbgenerated("(UUID_TO_BIN(UUID()))"))
Added one more parentheses around the function.
The model in the schema.prisma
file will be like this
model user {
id Bytes @default(dbgenerated("(UUID_TO_BIN(UUID()))")) @db.Binary(16)
name String @db.VarChar(100)
}
If @db.Binary(16)
is not mentioned, the default data type in the schema will be LONGBLOB
.
Use SELECT BIN_TO_UUID(id) FROM user
to view the actual UUID.