[PR #5858] [CLOSED] fix:#5849 default value in prisma schema #31882

Closed
opened 2026-04-17 22:45:34 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5858
Author: @rovertrack
Created: 11/8/2025
Status: Closed

Base: canaryHead: fix/prismaSchema


📝 Commits (1)

📊 Changes

1 file changed (+6 additions, -4 deletions)

View changed files

📝 packages/cli/src/generators/prisma.ts (+6 -4)

📄 Description

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 7c54162238. Summary will update automatically on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/5858 **Author:** [@rovertrack](https://github.com/rovertrack) **Created:** 11/8/2025 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `fix/prismaSchema` --- ### 📝 Commits (1) - [`7c54162`](https://github.com/better-auth/better-auth/commit/7c54162238249c9cd29222a6c32aa9df0ad95a11) fix:#5849 ### 📊 Changes **1 file changed** (+6 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `packages/cli/src/generators/prisma.ts` (+6 -4) </details> ### 📄 Description 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 7c54162238249c9cd29222a6c32aa9df0ad95a11. Summary will update automatically on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-17 22:45:34 -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#31882