[PR #4375] [MERGED] feat: add @default and @updatedAt for prisma generator #5342

Closed
opened 2026-03-13 12:19:27 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4375
Author: @himself65
Created: 9/3/2025
Status: Merged
Merged: 9/3/2025
Merged by: @himself65

Base: canaryHead: himself65/2025/09/02/db-generator


📝 Commits (9)

📊 Changes

21 files changed (+146 additions, -117 deletions)

View changed files

📝 packages/better-auth/src/__snapshots__/init.test.ts.snap (+3 -3)
📝 packages/better-auth/src/adapters/create-adapter/index.ts (+1 -1)
📝 packages/better-auth/src/db/get-tables.ts (+3 -3)
📝 packages/better-auth/src/db/internal-adapter.ts (+10 -4)
📝 packages/better-auth/src/db/schema.ts (+9 -15)
📝 packages/better-auth/src/plugins/two-factor/two-factor.test.ts (+1 -1)
📝 packages/better-auth/src/types/adapter.ts (+4 -1)
📝 packages/cli/src/generators/prisma.ts (+28 -0)
📝 packages/cli/test/__snapshots__/auth-schema-mysql-number-id.txt (+6 -7)
📝 packages/cli/test/__snapshots__/auth-schema-mysql.txt (+6 -7)
📝 packages/cli/test/__snapshots__/auth-schema-number-id.txt (+6 -7)
📝 packages/cli/test/__snapshots__/auth-schema-sqlite-number-id.txt (+6 -5)
📝 packages/cli/test/__snapshots__/auth-schema-sqlite.txt (+6 -5)
📝 packages/cli/test/__snapshots__/auth-schema.txt (+6 -7)
📝 packages/cli/test/__snapshots__/migrations.sql (+1 -1)
📝 packages/cli/test/__snapshots__/schema-mongodb.prisma (+9 -9)
📝 packages/cli/test/__snapshots__/schema-mysql-custom.prisma (+11 -11)
📝 packages/cli/test/__snapshots__/schema-mysql.prisma (+11 -11)
📝 packages/cli/test/__snapshots__/schema-numberid.prisma (+9 -9)
📝 packages/cli/test/__snapshots__/schema.prisma (+9 -9)

...and 1 more files

📄 Description

Summary by cubic

Add @default(now()) and @updatedAt to the Prisma generator so createdAt/updatedAt are auto-managed and boolean defaults are emitted. This reduces manual edits and keeps generated schemas consistent with runtime behavior.

  • New Features

    • Prisma generator sets @default(now()) on createdAt and @updatedAt on updatedAt.
    • Emits default(true|false) for booleans; supports Date defaults from functions; warns on unsupported defaults.
    • Applies onUpdate only to updatedAt; warns if used elsewhere.
    • Updated all Prisma snapshot tests.
  • Refactors

    • Zod schemas share a coreSchema for id, createdAt, and updatedAt defaults.
    • Adapter types now expose adapterConfig under options.
    • Internal adapter continues to set timestamps temporarily; createUser no longer forces emailVerified; userId comes from the created record.
    • get-tables sets emailVerified default as a boolean literal.

🔄 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/4375 **Author:** [@himself65](https://github.com/himself65) **Created:** 9/3/2025 **Status:** ✅ Merged **Merged:** 9/3/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `himself65/2025/09/02/db-generator` --- ### 📝 Commits (9) - [`e06d261`](https://github.com/better-auth/better-auth/commit/e06d2612909fed282a9d3b35b4830e84a920d696) feat: add `@default` and `@updatedAt` for prisma generator - [`efc57ca`](https://github.com/better-auth/better-auth/commit/efc57caccf351f73f019e21d2c027343e9c2876e) fix: required - [`7ec6b64`](https://github.com/better-auth/better-auth/commit/7ec6b640b9d47832d44987b11701fdcf2ab75f0a) fix: snapshot - [`c7abdb4`](https://github.com/better-auth/better-auth/commit/c7abdb4d4b9f5e7e189267539cedfa38d4113f3e) fix: test - [`fc2c0e5`](https://github.com/better-auth/better-auth/commit/fc2c0e5f07d158f0f017cb770795ea319190af66) fix: test - [`459e883`](https://github.com/better-auth/better-auth/commit/459e88316ec78036e8772b5d14ce344ad470e805) fix: test - [`fdee135`](https://github.com/better-auth/better-auth/commit/fdee13500d21ee6399abc9ed8d1ba499771b7a5f) fix: snapshot - [`d520101`](https://github.com/better-auth/better-auth/commit/d52010130a6712c8f1a401cadf61ba8bf32b8da6) fix: test - [`dabac15`](https://github.com/better-auth/better-auth/commit/dabac156d528705afb253b96e6c5ebc4ec8ffb4c) fix: snapshot ### 📊 Changes **21 files changed** (+146 additions, -117 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/__snapshots__/init.test.ts.snap` (+3 -3) 📝 `packages/better-auth/src/adapters/create-adapter/index.ts` (+1 -1) 📝 `packages/better-auth/src/db/get-tables.ts` (+3 -3) 📝 `packages/better-auth/src/db/internal-adapter.ts` (+10 -4) 📝 `packages/better-auth/src/db/schema.ts` (+9 -15) 📝 `packages/better-auth/src/plugins/two-factor/two-factor.test.ts` (+1 -1) 📝 `packages/better-auth/src/types/adapter.ts` (+4 -1) 📝 `packages/cli/src/generators/prisma.ts` (+28 -0) 📝 `packages/cli/test/__snapshots__/auth-schema-mysql-number-id.txt` (+6 -7) 📝 `packages/cli/test/__snapshots__/auth-schema-mysql.txt` (+6 -7) 📝 `packages/cli/test/__snapshots__/auth-schema-number-id.txt` (+6 -7) 📝 `packages/cli/test/__snapshots__/auth-schema-sqlite-number-id.txt` (+6 -5) 📝 `packages/cli/test/__snapshots__/auth-schema-sqlite.txt` (+6 -5) 📝 `packages/cli/test/__snapshots__/auth-schema.txt` (+6 -7) 📝 `packages/cli/test/__snapshots__/migrations.sql` (+1 -1) 📝 `packages/cli/test/__snapshots__/schema-mongodb.prisma` (+9 -9) 📝 `packages/cli/test/__snapshots__/schema-mysql-custom.prisma` (+11 -11) 📝 `packages/cli/test/__snapshots__/schema-mysql.prisma` (+11 -11) 📝 `packages/cli/test/__snapshots__/schema-numberid.prisma` (+9 -9) 📝 `packages/cli/test/__snapshots__/schema.prisma` (+9 -9) _...and 1 more files_ </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Add @default(now()) and @updatedAt to the Prisma generator so createdAt/updatedAt are auto-managed and boolean defaults are emitted. This reduces manual edits and keeps generated schemas consistent with runtime behavior. - **New Features** - Prisma generator sets @default(now()) on createdAt and @updatedAt on updatedAt. - Emits default(true|false) for booleans; supports Date defaults from functions; warns on unsupported defaults. - Applies onUpdate only to updatedAt; warns if used elsewhere. - Updated all Prisma snapshot tests. - **Refactors** - Zod schemas share a coreSchema for id, createdAt, and updatedAt defaults. - Adapter types now expose adapterConfig under options. - Internal adapter continues to set timestamps temporarily; createUser no longer forces emailVerified; userId comes from the created record. - get-tables sets emailVerified default as a boolean literal. <!-- 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-03-13 12:19:27 -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#5342