Native types for enums

Hi, I would like to add a native type to an enum field. Like that :
enum Role {
USER
ADMIN
}
model User {
role Role @db.VarChar(191)
}
enum Role {
USER
ADMIN
}
model User {
role Role @db.VarChar(191)
}
But when I do a prisma generate I get the following error : Attribute not known: "@db.VarChar". Are native types supported for enums?
3 Replies
RaphaelEtim
RaphaelEtim4mo ago
Hi @Baptiste Marchand Native types are not supported for enum fields. Native type attributes like @db.VarChar can only be applied to scalar fields, not enums.
Baptiste Marchand
Baptiste MarchandOP4mo ago
Ok thank you for your answer. FYI, having this feature would be helpful to migrate Prisma 1 codebases where enums are stored as strings.
RaphaelEtim
RaphaelEtim4mo ago
Can you please take a look at this upgrade guide from Prisma 1
Schema Incompatibilities | PostgreSQL | Prisma Documentation
Problems and workarounds for Prisma 1 and 2.0 schemas with PostgreSQL
Want results from more Discord servers?
Add your server