[PR #5864] fix:#5849 default value in prisma schema #5858 #5863 #14532

Closed
opened 2026-04-13 09:31:20 -05:00 by GiteaMirror · 0 comments
Owner

Original Pull Request: https://github.com/better-auth/better-auth/pull/5864

State: closed
Merged: No


as mentioned in #5849 the default value for Prisma schema where not generating properly,
it was because it was only looking out for the types other than number.

 additionalFields: {
      role: {
        type: "string",
        required: false,
        defaultValue: "user",
        input: false,
      },
    },

before

schema.prisma

model User {
  id            String    @id @default(uuid())
  name          String
  email         String
  emailVerified Boolean   @default(false)
  role String?
  createdAt     DateTime  @default(now())
  updatedAt     DateTime  @default(now()) @updatedAt


  @@unique([email])
  @@map("user")
}

after

schema.prisma

model User {
  id            String    @id @default(uuid())
  name          String
  email         String
  emailVerified Boolean   @default(false)
  role String? @default("user")
  createdAt     DateTime  @default(now())
  updatedAt     DateTime  @default(now()) @updatedAt
  

 

  @@unique([email])
  @@map("user")
}

now it adds the default value inPrisma schema
solves #5849.


Summary by cubic

Fixes #5849: Prisma schema generator now correctly emits default values for string, number, and boolean fields. Example: role String? becomes role String? @default("user").

  • Bug Fixes
    • Add quoting for string defaults: default("value").
    • Support numeric and boolean defaults: default(123), default(false).
    • Preserve special cases: createdAt default(now()), updatedAt @updatedAt.
    • Skip function defaults to avoid invalid Prisma output.

Written for commit 7375631b40. Summary will update automatically on new commits.

**Original Pull Request:** https://github.com/better-auth/better-auth/pull/5864 **State:** closed **Merged:** No --- as mentioned in #5849 the default value for Prisma schema where not generating properly, it was because it was only looking out for the types other than number. ``` additionalFields: { role: { type: "string", required: false, defaultValue: "user", input: false, }, }, ``` **before** > **schema.prisma** ``` model User { id String @id @default(uuid()) name String email String emailVerified Boolean @default(false) role String? createdAt DateTime @default(now()) updatedAt DateTime @default(now()) @updatedAt @@unique([email]) @@map("user") } ``` after > **schema.prisma** ``` model User { id String @id @default(uuid()) name String email String emailVerified Boolean @default(false) role String? @default("user") createdAt DateTime @default(now()) updatedAt DateTime @default(now()) @updatedAt @@unique([email]) @@map("user") } ``` now it adds the default value inPrisma schema solves #5849. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixes #5849: Prisma schema generator now correctly emits default values for string, number, and boolean fields. Example: role String? becomes role String? @default("user"). - **Bug Fixes** - Add quoting for string defaults: default("value"). - Support numeric and boolean defaults: default(123), default(false). - Preserve special cases: createdAt default(now()), updatedAt @updatedAt. - Skip function defaults to avoid invalid Prisma output. <sup>Written for commit 7375631b406207f230b2a5f8b7c3ad28e42e5335. Summary will update automatically on new commits.</sup> <!-- End of auto-generated description by cubic. -->
GiteaMirror added the pull-request label 2026-04-13 09:31:20 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#14532