[PR #4918] [MERGED] refactor: move db schema to core #31258

Closed
opened 2026-04-17 22:09:14 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

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

Base: canaryHead: himself65/2025/09/25/db-schema


📝 Commits (5)

  • ee4ef31 refactor: move db schema to core
  • 0336eff fix: use --project
  • 174a2a9 fix: cache type check
  • c2514c0 chore: use monorepo tsc -b
  • b90451a Merge branch 'canary' into himself65/2025/09/25/db-schema

📊 Changes

28 files changed (+310 additions, -238 deletions)

View changed files

📝 packages/better-auth/src/adapters/adapter-factory/index.ts (+2 -2)
📝 packages/better-auth/src/adapters/adapter-factory/types.ts (+9 -9)
📝 packages/better-auth/src/adapters/utils.ts (+2 -2)
📝 packages/better-auth/src/db/field.ts (+22 -127)
📝 packages/better-auth/src/db/get-migration.ts (+6 -6)
📝 packages/better-auth/src/db/get-schema.ts (+4 -3)
📝 packages/better-auth/src/db/get-tables.ts (+9 -29)
📝 packages/better-auth/src/db/index.ts (+1 -0)
📝 packages/better-auth/src/db/schema.ts (+4 -4)
📝 packages/better-auth/src/db/to-zod.ts (+6 -6)
📝 packages/better-auth/src/db/utils.ts (+4 -3)
📝 packages/better-auth/src/init.ts (+3 -7)
📝 packages/better-auth/src/plugins/additional-fields/client.ts (+5 -5)
📝 packages/better-auth/src/plugins/open-api/generator.ts (+9 -9)
📝 packages/better-auth/src/plugins/organization/client.ts (+6 -6)
📝 packages/better-auth/src/plugins/organization/routes/crud-access-control.test.ts (+2 -2)
📝 packages/better-auth/src/plugins/organization/types.ts (+6 -6)
📝 packages/better-auth/src/types/options.ts (+3 -3)
📝 packages/better-auth/src/types/plugins.ts (+2 -2)
📝 packages/better-auth/tsconfig.json (+2 -1)

...and 8 more files

📄 Description

This is a small goal of making separate plugin package and the dedicated client API happen


Summary by cubic

Moved DB schema types to @better-auth/core to centralize and share them across packages. Updated Better Auth and CLI to use the new types and paths, with deprecated aliases kept for 1.3.x to ease migration.

  • Refactors

    • Introduced DBFieldAttribute, DBFieldAttributeConfig, DBFieldType, BetterAuthDBSchema in core.
    • Replaced FieldAttribute and BetterAuthDbSchema usages across better-auth and CLI with core types.
    • better-auth now re-exports core DB types for compatibility.
    • Added core db entry to build and exports; updated typecheck to use tsc -b.
    • No runtime behavior changes; this is a type and import consolidation.
  • Migration

    • Prefer importing from @better-auth/core/db.
    • Type renames:
      • FieldAttribute → DBFieldAttribute
      • FieldAttributeConfig → DBFieldAttributeConfig
      • FieldType → DBFieldType
      • BetterAuthDbSchema → BetterAuthDBSchema
    • Deprecated aliases are still available until 1.4.x.
    • If you have custom plugins or generators, update imports and types accordingly. No DB migrations required.

🔄 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/4918 **Author:** [@himself65](https://github.com/himself65) **Created:** 9/26/2025 **Status:** ✅ Merged **Merged:** 9/26/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `himself65/2025/09/25/db-schema` --- ### 📝 Commits (5) - [`ee4ef31`](https://github.com/better-auth/better-auth/commit/ee4ef31b1cfa30cefa7e74a22a483e59b9c04a1c) refactor: move db schema to core - [`0336eff`](https://github.com/better-auth/better-auth/commit/0336effe695edff4d10e3d810a475aec7397a966) fix: use --project - [`174a2a9`](https://github.com/better-auth/better-auth/commit/174a2a9942ca5aced395e2d61245d6a67a3c699f) fix: cache type check - [`c2514c0`](https://github.com/better-auth/better-auth/commit/c2514c024be79ee66fcfd2566bc79803bd22437d) chore: use monorepo tsc -b - [`b90451a`](https://github.com/better-auth/better-auth/commit/b90451aeb797035544068fd13a34064f72b6732f) Merge branch 'canary' into himself65/2025/09/25/db-schema ### 📊 Changes **28 files changed** (+310 additions, -238 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/adapters/adapter-factory/index.ts` (+2 -2) 📝 `packages/better-auth/src/adapters/adapter-factory/types.ts` (+9 -9) 📝 `packages/better-auth/src/adapters/utils.ts` (+2 -2) 📝 `packages/better-auth/src/db/field.ts` (+22 -127) 📝 `packages/better-auth/src/db/get-migration.ts` (+6 -6) 📝 `packages/better-auth/src/db/get-schema.ts` (+4 -3) 📝 `packages/better-auth/src/db/get-tables.ts` (+9 -29) 📝 `packages/better-auth/src/db/index.ts` (+1 -0) 📝 `packages/better-auth/src/db/schema.ts` (+4 -4) 📝 `packages/better-auth/src/db/to-zod.ts` (+6 -6) 📝 `packages/better-auth/src/db/utils.ts` (+4 -3) 📝 `packages/better-auth/src/init.ts` (+3 -7) 📝 `packages/better-auth/src/plugins/additional-fields/client.ts` (+5 -5) 📝 `packages/better-auth/src/plugins/open-api/generator.ts` (+9 -9) 📝 `packages/better-auth/src/plugins/organization/client.ts` (+6 -6) 📝 `packages/better-auth/src/plugins/organization/routes/crud-access-control.test.ts` (+2 -2) 📝 `packages/better-auth/src/plugins/organization/types.ts` (+6 -6) 📝 `packages/better-auth/src/types/options.ts` (+3 -3) 📝 `packages/better-auth/src/types/plugins.ts` (+2 -2) 📝 `packages/better-auth/tsconfig.json` (+2 -1) _...and 8 more files_ </details> ### 📄 Description This is a small goal of making separate plugin package and the dedicated client API happen <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Moved DB schema types to @better-auth/core to centralize and share them across packages. Updated Better Auth and CLI to use the new types and paths, with deprecated aliases kept for 1.3.x to ease migration. - **Refactors** - Introduced DBFieldAttribute, DBFieldAttributeConfig, DBFieldType, BetterAuthDBSchema in core. - Replaced FieldAttribute and BetterAuthDbSchema usages across better-auth and CLI with core types. - better-auth now re-exports core DB types for compatibility. - Added core db entry to build and exports; updated typecheck to use tsc -b. - No runtime behavior changes; this is a type and import consolidation. - **Migration** - Prefer importing from @better-auth/core/db. - Type renames: - FieldAttribute → DBFieldAttribute - FieldAttributeConfig → DBFieldAttributeConfig - FieldType → DBFieldType - BetterAuthDbSchema → BetterAuthDBSchema - Deprecated aliases are still available until 1.4.x. - If you have custom plugins or generators, update imports and types accordingly. No DB migrations required. <!-- 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-17 22:09:14 -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#31258