The model "user" was not found in the schema object

I'm not sure what is going on, I've already specified it in the schema:
export const auth = betterAuth({
plugins: [bearer(), jwt()],
database: drizzleAdapter(db, {
provider: "pg",
schema: {
user: schema.user,
session: schema.session,
account: schema.account,
verification: schema.verification,
jwks: schema.jwks,
}
}),
emailAndPassword: {
enabled: true,
},
trustedOrigins: ["http://localhost:3001"],
});
export const auth = betterAuth({
plugins: [bearer(), jwt()],
database: drizzleAdapter(db, {
provider: "pg",
schema: {
user: schema.user,
session: schema.session,
account: schema.account,
verification: schema.verification,
jwks: schema.jwks,
}
}),
emailAndPassword: {
enabled: true,
},
trustedOrigins: ["http://localhost:3001"],
});
This is the schema object being used by the betterAuth config:
import "dotenv/config";
import { drizzle } from "drizzle-orm/node-postgres";
import { user, session, account, verification, jwks } from "../../auth-schema";

export const schema = {
user,
session,
account,
verification,
jwks,
};

export const db = drizzle(process.env.DATABASE_URL!, { schema });
import "dotenv/config";
import { drizzle } from "drizzle-orm/node-postgres";
import { user, session, account, verification, jwks } from "../../auth-schema";

export const schema = {
user,
session,
account,
verification,
jwks,
};

export const db = drizzle(process.env.DATABASE_URL!, { schema });
And auth-schema is the file which is automatically generated.
export const user = pgTable("user", {
id: text("id").primaryKey(),
name: text("name").notNull(),
email: text("email").notNull().unique(),
emailVerified: boolean("email_verified")
.$defaultFn(() => false)
.notNull(),
image: text("image"),
createdAt: timestamp("created_at")
.$defaultFn(() => /* @__PURE__ */ new Date())
.notNull(),
updatedAt: timestamp("updated_at")
.$defaultFn(() => /* @__PURE__ */ new Date())
.notNull(),
});

// Others...
export const user = pgTable("user", {
id: text("id").primaryKey(),
name: text("name").notNull(),
email: text("email").notNull().unique(),
emailVerified: boolean("email_verified")
.$defaultFn(() => false)
.notNull(),
image: text("image"),
createdAt: timestamp("created_at")
.$defaultFn(() => /* @__PURE__ */ new Date())
.notNull(),
updatedAt: timestamp("updated_at")
.$defaultFn(() => /* @__PURE__ */ new Date())
.notNull(),
});

// Others...
Any idea what is going on? I've checked previous messages here and the solution for them has being to add the schema in the betterAuth config, but I'm already doing that.
Solution:
Well apparently the TS output was originally /dist/app.js, but somehow - and I still don't know why/how, it started outputting to /dist/src/app.js, so basically I was 'working' on an older code.
Jump to solution
1 Reply
Solution
Andres
Andres4w ago
Well apparently the TS output was originally /dist/app.js, but somehow - and I still don't know why/how, it started outputting to /dist/src/app.js, so basically I was 'working' on an older code.

Did you find this page helpful?