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
}


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()),
});

and it is present in the actual database
Solution
try this
database: drizzleAdapter(db, {
    provider: "pg",
    schema: {
      user,
      session,
      account,
      verification,
    },
  }),
Was this page helpful?