[PR #7534] [MERGED] feat(db): store verification data in secondary storage #7382

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7534
Author: @Paola3stefania
Created: 1/21/2026
Status: Merged
Merged: 1/26/2026
Merged by: @Paola3stefania

Base: feat/verification-token-storageHead: feat/verification-secondary-storage


📝 Commits (7)

  • 1f3f281 feat: add storeInDatabase
  • 296eb76 feat: seconday storage in internal adapter
  • 023638f feat: create test
  • 8e79e06 cleanup
  • c2d5e1d add json doc
  • eb8d8b2 Merge branch 'feat/verification-token-storage' into feat/verification-secondary-storage
  • 9b6501f feat: add table

📊 Changes

5 files changed (+378 additions, -79 deletions)

View changed files

📝 packages/better-auth/src/db/internal-adapter.test.ts (+207 -2)
📝 packages/better-auth/src/db/internal-adapter.ts (+90 -40)
📝 packages/core/src/db/get-tables.ts (+43 -37)
📝 packages/core/src/db/test/get-tables.test.ts (+33 -0)
📝 packages/core/src/types/init-options.ts (+5 -0)

📄 Description

Summary by cubic

Store verification data in secondary storage by default to reduce database writes and improve performance, with an option to also persist to the database. Adds TTL handling from expiresAt and smarter fallback reads.

  • New Features

    • verification.storeInDatabase option (default false).
    • Write verification to secondaryStorage with TTL derived from expiresAt.
    • Read verification from secondaryStorage first; fallback to DB only when storeInDatabase is true.
    • Fallback to plain identifier in secondaryStorage for migration.
    • Delete by identifier removes from secondaryStorage and, when enabled, the database.
    • Shared getTTLSeconds helper applied to session caching.
  • Migration

    • findVerificationValue returns null (not undefined) when not found.
    • If secondary storage is enabled and storeInDatabase is false, verification data is not stored in the DB and the verification table is omitted from the schema. Enable storeInDatabase if your tooling queries the DB or you need the table.
    • deleteVerificationValue is a no-op in secondary-only mode; use deleteVerificationByIdentifier instead.

Written for commit 9b6501f4e6. Summary will update 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/7534 **Author:** [@Paola3stefania](https://github.com/Paola3stefania) **Created:** 1/21/2026 **Status:** ✅ Merged **Merged:** 1/26/2026 **Merged by:** [@Paola3stefania](https://github.com/Paola3stefania) **Base:** `feat/verification-token-storage` ← **Head:** `feat/verification-secondary-storage` --- ### 📝 Commits (7) - [`1f3f281`](https://github.com/better-auth/better-auth/commit/1f3f281a78847e7470947bea1d13f46798bbbe97) feat: add storeInDatabase - [`296eb76`](https://github.com/better-auth/better-auth/commit/296eb762e205747c84f3c38d23c14570ffee7759) feat: seconday storage in internal adapter - [`023638f`](https://github.com/better-auth/better-auth/commit/023638fe7a3fcb130453194408770fdf875a916e) feat: create test - [`8e79e06`](https://github.com/better-auth/better-auth/commit/8e79e0620dc10f82b193dc05756a48bf53a2da5d) cleanup - [`c2d5e1d`](https://github.com/better-auth/better-auth/commit/c2d5e1d6cd97bfe2c6396c06801e429d519c4660) add json doc - [`eb8d8b2`](https://github.com/better-auth/better-auth/commit/eb8d8b260976f6bdcf65d7fc6400ce842df10c35) Merge branch 'feat/verification-token-storage' into feat/verification-secondary-storage - [`9b6501f`](https://github.com/better-auth/better-auth/commit/9b6501f4e6a1225ca899b1ec12b4c9b92199e440) feat: add table ### 📊 Changes **5 files changed** (+378 additions, -79 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/db/internal-adapter.test.ts` (+207 -2) 📝 `packages/better-auth/src/db/internal-adapter.ts` (+90 -40) 📝 `packages/core/src/db/get-tables.ts` (+43 -37) 📝 `packages/core/src/db/test/get-tables.test.ts` (+33 -0) 📝 `packages/core/src/types/init-options.ts` (+5 -0) </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Store verification data in secondary storage by default to reduce database writes and improve performance, with an option to also persist to the database. Adds TTL handling from expiresAt and smarter fallback reads. - **New Features** - verification.storeInDatabase option (default false). - Write verification to secondaryStorage with TTL derived from expiresAt. - Read verification from secondaryStorage first; fallback to DB only when storeInDatabase is true. - Fallback to plain identifier in secondaryStorage for migration. - Delete by identifier removes from secondaryStorage and, when enabled, the database. - Shared getTTLSeconds helper applied to session caching. - **Migration** - findVerificationValue returns null (not undefined) when not found. - If secondary storage is enabled and storeInDatabase is false, verification data is not stored in the DB and the verification table is omitted from the schema. Enable storeInDatabase if your tooling queries the DB or you need the table. - deleteVerificationValue is a no-op in secondary-only mode; use deleteVerificationByIdentifier instead. <sup>Written for commit 9b6501f4e6a1225ca899b1ec12b4c9b92199e440. Summary will update 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-03-13 13:34:11 -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#7382