[PR #5880] [CLOSED] fix(adapter): default value in prisma schema #23192

Closed
opened 2026-04-15 21:32:30 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

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

Base: canaryHead: dbdefault


📝 Commits (10+)

📊 Changes

5 files changed (+270 additions, -6 deletions)

View changed files

📝 packages/cli/src/generators/prisma.ts (+32 -4)
packages/cli/test/__snapshots__/schema-defaultvalues.prisma (+85 -0)
📝 packages/cli/test/__snapshots__/schema-mysql-custom.prisma (+2 -2)
packages/cli/test/__snapshots__/schema-mysql-defaultvalues.prisma (+85 -0)
📝 packages/cli/test/generate.test.ts (+66 -0)

📄 Description

Summary by cubic

Fix default value generation in Prisma schema so fields get valid defaults across providers. For MySQL, avoid invalid defaults on TEXT and support long string defaults via dbgenerated.

  • Bug Fixes
    • Apply default(...) for string, boolean, and number fields; for MySQL strings, only when the value is <255 chars.
    • For MySQL strings: use @db.Text only when there’s no default or the default is >255 chars; for long defaults, set default(dbgenerated(...)).
    • Added snapshot tests for PostgreSQL and MySQL; updated MySQL custom snapshots for role and status defaults.

Written for commit 4c931cb545. 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/5880 **Author:** [@rovertrack](https://github.com/rovertrack) **Created:** 11/10/2025 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `dbdefault` --- ### 📝 Commits (10+) - [`7c54162`](https://github.com/better-auth/better-auth/commit/7c54162238249c9cd29222a6c32aa9df0ad95a11) fix:#5849 - [`f7ed3e6`](https://github.com/better-auth/better-auth/commit/f7ed3e6c51cb574e900fef89f8fa7b22ded57fcb) fix(prismaSchema):defaultValue is not applying in prisma schema (#5849 - [`23121fc`](https://github.com/better-auth/better-auth/commit/23121fc97adb7dc8f9d13e5e0be9ca315892a265) fix:better-auth#5849 default value bug fix for prisma schema - [`4e98b80`](https://github.com/better-auth/better-auth/commit/4e98b80fff2a952e47a4ab267faeda4134794839) Merge branch 'fix/schema' of https://github.com/rovertrack/better-auth into fix/schema - [`7375631`](https://github.com/better-auth/better-auth/commit/7375631b406207f230b2a5f8b7c3ad28e42e5335) fix(prisma): add default values for role and status fields in schema - [`f520674`](https://github.com/better-auth/better-auth/commit/f520674512f8541b7b01dd847637fb0d86c2de62) Merge branch 'better-auth:canary' into fix/schema - [`e5b02b2`](https://github.com/better-auth/better-auth/commit/e5b02b2a58aa3167d85b9fb40f463a828800c627) fix(prisma): restrict default value application for string fields to non-mysql providers - [`d9c411c`](https://github.com/better-auth/better-auth/commit/d9c411c596c57a4a6b9cb2c6a068565290be0d27) Merge branch 'fix/schemaerror' of https://github.com/rovertrack/better-auth into fix/schemaerror - [`1576b22`](https://github.com/better-auth/better-auth/commit/1576b22adfcb049595ba467fe0a50fd23337294e) fix(adapter): enhance schema generation to support default values thorugh prisma - [`40bb5d1`](https://github.com/better-auth/better-auth/commit/40bb5d122b652846b6660568448924912faf58ae) Merge branch 'better-auth:canary' into fix/schemaerror ### 📊 Changes **5 files changed** (+270 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `packages/cli/src/generators/prisma.ts` (+32 -4) ➕ `packages/cli/test/__snapshots__/schema-defaultvalues.prisma` (+85 -0) 📝 `packages/cli/test/__snapshots__/schema-mysql-custom.prisma` (+2 -2) ➕ `packages/cli/test/__snapshots__/schema-mysql-defaultvalues.prisma` (+85 -0) 📝 `packages/cli/test/generate.test.ts` (+66 -0) </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Fix default value generation in Prisma schema so fields get valid defaults across providers. For MySQL, avoid invalid defaults on TEXT and support long string defaults via dbgenerated. - **Bug Fixes** - Apply default(...) for string, boolean, and number fields; for MySQL strings, only when the value is <255 chars. - For MySQL strings: use @db.Text only when there’s no default or the default is >255 chars; for long defaults, set default(dbgenerated(...)). - Added snapshot tests for PostgreSQL and MySQL; updated MySQL custom snapshots for role and status defaults. <sup>Written for commit 4c931cb5454cd375aa126bda127fff40ec2e7b69. 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-15 21:32:30 -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#23192