Skip to content

Better Auth - Schema + Compatibility - #4284

Open
devkiran wants to merge 3 commits into
mainfrom
better-auth-1
Open

Better Auth - Schema + Compatibility#4284
devkiran wants to merge 3 commits into
mainfrom
better-auth-1

Conversation

@devkiran

@devkiran devkiran commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Bug Fixes

    • Improved account verification handling during sign-up and password resets.
    • Verified account status is now preserved consistently across authentication flows.
  • Authentication

    • Enhanced support for account updates, sessions, verification tokens, and authentication metadata.
    • Improved compatibility with current authentication behavior while preserving password reset and account recovery functionality.

@vercel

vercel Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
dub Ready Ready Preview Aug 7, 2026 11:35am

Request Review

@devkiran
devkiran requested a review from steven-tey August 7, 2026 09:13
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 25f4f95f-252a-4309-81b7-3cfa1cb16108

📥 Commits

Reviewing files that changed from the base of the PR and between 2bb37b3 and 1cfcfe4.

📒 Files selected for processing (1)
  • apps/web/prisma/schema/schema.prisma
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/web/prisma/schema/schema.prisma

📝 Walkthrough

Walkthrough

The PR adds Better Auth-compatible Prisma fields and models. It updates the authentication adapter and password reset flow to persist emailVerifiedBa. Account creation and seed scripts now set the flag for verified users.

Changes

Authentication verification support

Layer / File(s) Summary
Authentication schema contract
apps/web/prisma/schema/schema.prisma
The User model adds verification metadata. Account, Session, and Verification support Better Auth fields, timestamps, relations, indexes, and uniqueness constraints.
Authentication adapter persistence
apps/web/lib/auth/options.ts
The custom Prisma adapter persists verification fields during user creation and updates users by ID through updateUser.
Verification flag propagation
apps/web/app/api/auth/reset-password/route.ts, apps/web/lib/actions/create-user-account.ts, apps/web/playwright/seed.ts, apps/web/scripts/dev/seed-partner-enrollment.ts, apps/web/scripts/dev/seed.ts
Password reset, application account creation, and seed user creation now set emailVerifiedBa: true.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: steven-tey

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the Better Auth schema and compatibility changes in the pull request.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch better-auth-1

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/web/lib/auth/options.ts`:
- Around line 67-70: Update the emailVerified update object so that whenever
emailVerified !== undefined, it also assigns emailVerifiedBa to
Boolean(emailVerified), including when verification is cleared with null; remove
the conditional true-only assignment while preserving the surrounding update
flow.

In `@apps/web/prisma/schema/schema.prisma`:
- Around line 15-16: Backfill Better Auth verification for existing verified
users: add a Prisma database migration updating User rows with non-null
emailVerified so emailVerifiedBa is true, and update existing seeded/fixture
users in apps/web/playwright/seed.ts to use equivalent values; no direct change
is required in apps/web/app/api/auth/reset-password/route.ts because the stale
production data is corrected by the migration.
- Around line 92-93: Update the migration for the Account model’s updatedAt
column to populate existing rows with a valid timestamp before enforcing the
required NOT NULL constraint. Preserve the schema’s `@updatedAt` behavior while
ensuring historical Account records receive a value during migration.
- Around line 102-114: Update CustomPrismaAdapter’s session
methods—getSessionAndUser(), createSession(), updateSession(), and
deleteSession()—to map the adapter’s sessionToken and expires values to the
Prisma Session model’s token and expiresAt fields. Ensure all session reads,
inserts, updates, and deletes use the renamed fields while preserving the
existing adapter behavior.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 9ed6a64b-f443-4165-9ede-2bbdaa6b428a

📥 Commits

Reviewing files that changed from the base of the PR and between 3f68d6a and a843996.

📒 Files selected for processing (7)
  • apps/web/app/api/auth/reset-password/route.ts
  • apps/web/lib/actions/create-user-account.ts
  • apps/web/lib/auth/options.ts
  • apps/web/playwright/seed.ts
  • apps/web/prisma/schema/schema.prisma
  • apps/web/scripts/dev/seed-partner-enrollment.ts
  • apps/web/scripts/dev/seed.ts

Comment thread apps/web/lib/auth/options.ts
Comment thread apps/web/prisma/schema/schema.prisma
Comment thread apps/web/prisma/schema/schema.prisma Outdated
Comment thread apps/web/prisma/schema/schema.prisma
@devkiran

devkiran commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai made some changes, review the comments

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

@devkiran I will review the updated changes and the existing review comments.

⚠️ Action not completed

Already reviewed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant