You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
@default on a field of a @map-ed enum emits the enum name as the column default #2868
When an enum member has a @map-ed value and a field uses it as the default, db push emits the enum name rather than the mapped database value as the column default. On PostgreSQL table creation fails.
Repro
enum PostStatus {
DRAFT @map('draft')
ACTIVE @map('active')
}
model User {
id Int @id @default(autoincrement())
status PostStatus @default(DRAFT)
}
Pushing this schema to PostgreSQL fails with:
invalid input value for enum "PostStatus": "DRAFT"
The generated DDL contains DEFAULT 'DRAFT' while the PostgreSQL enum type only has the values 'draft' and 'active'.
Where
packages/orm/src/client/helpers/schema-db-pusher.ts, the col.defaultTo(fieldDef.default) branch. The enum type itself is created with the mapped values (see the @map handling a few lines above in the same file), but the default is passed through unmapped.
Found while probing mapped-enum behavior for #2807.
Hi, I'd like to work on this one. The schema pusher passes the enum member name to the column default without applying @map. I plan to convert the default to its mapped value, reusing the same lookup the enum type creation already does. I'll add issue-2868.test.ts to the regression tests, covering a database-defaulted row on all three providers. Are you happy for me to take it?
Activity
jkugsiya commentedon Oct 13, 2026
Hi, I'd like to work on this one. The schema pusher passes the enum member name to the column default without applying
@map. I plan to convert the default to its mapped value, reusing the same lookup the enum type creation already does. I'll addissue-2868.test.tsto the regression tests, covering a database-defaulted row on all three providers. Are you happy for me to take it?