Custom tables - The field "userId" does not exist in the schema for the model "account"

I have an issue with my custom tables. I edited userId from account table but i dont understand why it doesn't work propertly. I get this error:
[A [BetterAuthError]: The field "userId" does not exist in the schema for the model "account". Please update your schema.] {
cause: undefined
}
[A [BetterAuthError]: The field "userId" does not exist in the schema for the model "account". Please update your schema.] {
cause: undefined
}
auth.ts
import dotenv from "dotenv";
import { betterAuth } from "better-auth";
import { admin, organization } from "better-auth/plugins";
import { drizzleAdapter } from "better-auth/adapters/drizzle";
import { v7 as uuidv7 } from "uuid";
import argon2 from "argon2";
import { db } from "../db/drizzle";
import { accounts, operators } from "../db/schema/auth-schema";

dotenv.config();

const argon2Verify = async (data: { hash: string; password: string }): Promise<boolean> => {
const { hash, password } = data;
return argon2.verify(hash, password);
};

export const auth = betterAuth({
database: drizzleAdapter(db, {
provider: "pg",
usePlural: true,
schema: {
operators,
accounts,
},
}),
plugins: [
admin(),
organization({
allowUserToCreateOrganization: async () => false,
}),
],
emailAndPassword: {
enabled: true,
password: {
hash: argon2.hash,
verify: argon2Verify,
},
},
user: {
modelName: "operators",
},
account: {
fields: {
userId: "operation_id",
},
},
});
import dotenv from "dotenv";
import { betterAuth } from "better-auth";
import { admin, organization } from "better-auth/plugins";
import { drizzleAdapter } from "better-auth/adapters/drizzle";
import { v7 as uuidv7 } from "uuid";
import argon2 from "argon2";
import { db } from "../db/drizzle";
import { accounts, operators } from "../db/schema/auth-schema";

dotenv.config();

const argon2Verify = async (data: { hash: string; password: string }): Promise<boolean> => {
const { hash, password } = data;
return argon2.verify(hash, password);
};

export const auth = betterAuth({
database: drizzleAdapter(db, {
provider: "pg",
usePlural: true,
schema: {
operators,
accounts,
},
}),
plugins: [
admin(),
organization({
allowUserToCreateOrganization: async () => false,
}),
],
emailAndPassword: {
enabled: true,
password: {
hash: argon2.hash,
verify: argon2Verify,
},
},
user: {
modelName: "operators",
},
account: {
fields: {
userId: "operation_id",
},
},
});
No description
No description
1 Reply
roze789
roze789OP2mo ago
SvelteKit: 2.15.1 / better-auth: 1.1.8

Did you find this page helpful?