Model "user" was not found in the database schema object with drizzle

2025-03-04T07:21:37.262Z ERROR [Better Auth]: BetterAuthError [Error [BetterAuthError]: [# Drizzle Adapter]: The model "user" was not found in the schema object. Please pass the schema directly to the adapter options.] {
cause: undefined
}
2025-03-04T07:21:37.262Z ERROR [Better Auth]: BetterAuthError [Error [BetterAuthError]: [# Drizzle Adapter]: The model "user" was not found in the schema object. Please pass the schema directly to the adapter options.] {
cause: undefined
}
even though i clearly defined it:
export const user = pgTable("user", {
id: text().primaryKey(),
name: text(),
email: text(),
emailVerified: text(),
image: text(),
finishedOnboarding: boolean(),
createdAt: date().defaultNow(),
updatedAt: date()
.defaultNow()
.$onUpdate(() => Date()),
});
export const user = pgTable("user", {
id: text().primaryKey(),
name: text(),
email: text(),
emailVerified: text(),
image: text(),
finishedOnboarding: boolean(),
createdAt: date().defaultNow(),
updatedAt: date()
.defaultNow()
.$onUpdate(() => Date()),
});
and it is present in the actual database
Solution:
try this ```database: drizzleAdapter(db, { provider: "pg", schema: { user,...
Jump to solution
9 Replies
preAGIcoder
preAGIcoder2mo ago
@aa55h can you share your auth.ts file?
aa55h
aa55hOP2mo ago
sure
export const auth = betterAuth({
database: drizzleAdapter(db, {
provider: "pg",
}),
emailAndPassword: {
enabled: true,
},
});
export const auth = betterAuth({
database: drizzleAdapter(db, {
provider: "pg",
}),
emailAndPassword: {
enabled: true,
},
});
Solution
preAGIcoder
preAGIcoder2mo ago
try this
database: drizzleAdapter(db, {
provider: "pg",
schema: {
user,
session,
account,
verification,
},
}),
database: drizzleAdapter(db, {
provider: "pg",
schema: {
user,
session,
account,
verification,
},
}),
preAGIcoder
preAGIcoder2mo ago
@aa55h to be clear pass the drizzle schemas here lmk if it works
aa55h
aa55hOP2mo ago
Yes one sec @preAGIcoder it seems like it could work, but can i pass the database url like this:
DATABASE_URL=postgres://postgres:[email protected]:5431/database
DATABASE_URL=postgres://postgres:[email protected]:5431/database
?
aa55h
aa55hOP2mo ago
cause now im just getting
No description
aa55h
aa55hOP2mo ago
oh nvm im stupid i was using wrong driver i guess? seems like
preAGIcoder
preAGIcoder2mo ago
is it solved?
aa55h
aa55hOP2mo ago
yes

Did you find this page helpful?