Drizzle ORM v1 Compatibility#
Drizzle ORM v1 (release candidate as 1.0.0-rc.x) ships a redesigned relations API — Relations v2 — that replaces the per-table relations() helper with a unified defineRelations() / defineRelationsPart() API. Better Auth added native support in @better-auth/drizzle-adapter@1.7.0-beta.10 (via PR #9489, included in the v1.7 release) through a new relations-v2 package entry point.
The two concrete breakages with Drizzle v1 on better-auth ≤ 1.6.x:
experimental.joins→ HTTP 500: The adapter expected old-style per-tableRelationsclass instances; Drizzle v1'sdefineRelations()object was not recognized, so all joined-query endpoints threw at runtime.- CLI generates invalid schema:
auth generateemittedimport { relations } from "drizzle-orm"andrelations(...)exports, butrelationsis no longer exported from the rootdrizzle-ormpackage in v1, producing a TypeScript error on import.
The relations-v2 Entry Point#
For Drizzle ORM v1 projects on better-auth ≥ 1.7, change the adapter import:
// auth.ts
import { drizzleAdapter } from "@better-auth/drizzle-adapter/relations-v2";
import * as schema from "./schema";
export const auth = betterAuth({
database: drizzleAdapter(db, { provider: "pg", schema }),
});
Importing from /relations-v2 activates the adapter path that understands Drizzle v1's defineRelations() / defineRelationsPart() types for relational queries. Using the old default import (better-auth/adapters/drizzle or @better-auth/drizzle-adapter) with Drizzle v1 and experimental.joins: true will still fail at runtime.
CLI Schema Generation: defineRelationsPart#
After updating to v1.7 and regenerating with npx auth@rc generate, the output uses defineRelationsPart instead of relations():
- Before (Drizzle v0.x output):
export const userRelations = relations(user, ({ many }) => ({ ... })) - After (Drizzle v1.x output): Relations are emitted via
defineRelationsPart, so the generated auth schema can be merged alongside your app's own relations without changing the database structure.
defineRelationsPart is used instead of defineRelations because Drizzle v1 only accepts one "main" relations object from defineRelations. The CLI generates a part that your app spreads in, leaving your app's defineRelations call intact.
Drizzle instance setup after regeneration#
import { drizzle } from "drizzle-orm/postgres-js";
import { relations as appRelations } from "./app-schema";
import { relations as authRelations } from "./schema"; // generated by CLI
export const db = drizzle({
client,
// authRelations uses defineRelationsPart; must come after the main relations.
relations: { ...appRelations, ...authRelations },
});
As of Drizzle v1 RC,
schemano longer needs to be passed to the Drizzle instance separately — onlyrelationsis required.
experimental.joins and Drizzle v1#
The adapter's join logic checks options.experimental?.joins, then calls db.query[queryModel].findFirst/findMany(...) with a with: clause. With Drizzle v0.x, db.query is populated by per-table Relations objects exported from the schema; with v1, it is populated by passing relations to the drizzle() constructor. The relations-v2 entry point corrects how the adapter inspects and uses the db.query object. Without it, you get runtime errors such as Unknown relational filter field: "decoder".
Version Compatibility#
| better-auth | Drizzle v0.x | Drizzle v1.x |
|---|---|---|
| ≤ 1.6.x | ✅ Default adapter | ❌ Not supported |
| ≥ 1.7.0 (RC+) | ✅ Default adapter | ✅ Use /relations-v2 entry point |
Known Issues (as of 2026-07-09)#
- CLI still emits
relations()on v1.7-rc.1 if the adapter import is not updated: Issue #10317 confirms the oldrelations()format is generated unless the auth config already imports from@better-auth/drizzle-adapter/relations-v2. Switching the import and re-running the CLI resolves it. experimental.joinsfailures on ≤ 1.6.x: The only in-place workaround is disablingexperimental.joinsuntil upgrading to v1.7.
Key References#
| Resource | Link |
|---|---|
| Adapter source | packages/drizzle-adapter/src/drizzle-adapter.ts |
| PR #9489 (v1 support) | github.com/better-auth/better-auth/pull/9489 |
| v1.7 RC release notes | better-auth.com/blog/1-7-rc#drizzle-relations-v2 |
| Drizzle v1 migration guide | orm.drizzle.team/docs/relations-v1-v2 |