[PR #2771] [CLOSED] issue-2431: feat - fixed prisma schema to avoid validation errors #4478

Closed
opened 2026-03-13 11:48:35 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/2771
Author: @iamsg97
Created: 5/24/2025
Status: Closed

Base: mainHead: feature/issue-2431


📝 Commits (3)

📊 Changes

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

View changed files

📝 dev/bun/prisma/schema.prisma (+44 -4)

📄 Description

Issue 2431 Fix

You can find the issue here

Fixed prisma schema to avoid while running bunx @better-auth/cli@latest generate

When we run bunx @better-auth/cli@latest generate, prisma will follow its naming convention and will name Session[] -> sessions and not Session, the schema already had two such params Session (as Session[]) and Account (as Account[]), there by duplicate sessions and accounts, causing issue. Renaming the existing Session and Account with sessions and accounts, hence averting the issue. Furthermore, in SsoProvider model have userId which is optional, but User (which contains userId) was a mandate, that's not possible. So made User also as optional.

Please do let me know, if there is something that I've done incorrectly, I will be happy to rectify it

After successfull prisma migration

image

image

Cheers,
Suvadeep


🔄 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/2771 **Author:** [@iamsg97](https://github.com/iamsg97) **Created:** 5/24/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feature/issue-2431` --- ### 📝 Commits (3) - [`0f82888`](https://github.com/better-auth/better-auth/commit/0f828886c182fc79c6a12c7302be08578e44b47c) issue-2431: feat - fixed prisma schema to avoid while running bunx @better-auth/cli@latest generate - [`712f021`](https://github.com/better-auth/better-auth/commit/712f02163a299ae099fab10348e18cd75534545a) issue-2431: fix: added @default for createdAt and updatedAt - [`9715231`](https://github.com/better-auth/better-auth/commit/9715231c0dd97df5e5abfd9a2befb06166f06aac) Merge branch 'main' of https://github.com/iamsg97/better-auth into feature/issue-2431 ### 📊 Changes **1 file changed** (+44 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `dev/bun/prisma/schema.prisma` (+44 -4) </details> ### 📄 Description # Issue 2431 Fix You can find the issue [here](https://github.com/better-auth/better-auth/issues/2431) **Fixed prisma schema to avoid while running `bunx @better-auth/cli@latest generate`** When we run `bunx @better-auth/cli@latest generate`, `prisma` will follow its naming convention and will name `Session[]` -> `sessions` and not `Session`, the schema already had two such params `Session` (as `Session[]`) and `Account` (as `Account[]`), there by duplicate `sessions` and `accounts`, causing issue. Renaming the existing `Session` and `Account` with `sessions` and `accounts`, hence averting the issue. Furthermore, in `SsoProvider` model have `userId` which is optional, but `User` (which contains `userId`) was a mandate, that's not possible. So made `User` also as optional. Please do let me know, if there is something that I've done incorrectly, I will be happy to rectify it After successfull prisma migration ![image](https://github.com/user-attachments/assets/c7ebd24d-17c6-4cdd-8f50-9f96109db89d) ![image](https://github.com/user-attachments/assets/41b3daf8-bf24-45c2-9340-8ae9b7dfe5c5) Cheers, Suvadeep --- <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-03-13 11:48:35 -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#4478