Kinan
Kinan
BABetter Auth
Created by Kinan on 5/22/2025 in #help
CORS "preflight response did not succeed" issue
Firefox CORS errors
4 replies
BABetter Auth
Created by Kinan on 5/4/2025 in #help
How to configure custom ID column names (e.g., id_user, id_session) ?
Hello everyone, I'm trying to customize the ID column names in my database schema. By default, better-auth uses id for the user table, id for the session table, etc. I'd like to use id_user, id_session, etc., instead. I attempted to configure this in the auth.ts file like this :
export const auth = betterAuth({
database: drizzleAdapter(db, {
provider: "pg",
schema: schema,
}),
// ... other configurations ...

/* BA Core schema change */
user: {
fields: {
// Trying to map the internal 'id' field to my 'id_user' column
id_user: "id_user" // <-- This is where I'm attempting the configuration
},
additionalFields: {
first_name: {
type: "string",
required: true,
},
},
},
});
export const auth = betterAuth({
database: drizzleAdapter(db, {
provider: "pg",
schema: schema,
}),
// ... other configurations ...

/* BA Core schema change */
user: {
fields: {
// Trying to map the internal 'id' field to my 'id_user' column
id_user: "id_user" // <-- This is where I'm attempting the configuration
},
additionalFields: {
first_name: {
type: "string",
required: true,
},
},
},
});
However, I'm getting the following TypeScript error on the id_user: "id_user" line:
Object literal may only specify known properties, and 'id_user' does not exist in type 'Partial<Record<"name" | "email" | "emailVerified" | "createdAt" | "updatedAt" | "image", string>>'.
Object literal may only specify known properties, and 'id_user' does not exist in type 'Partial<Record<"name" | "email" | "emailVerified" | "createdAt" | "updatedAt" | "image", string>>'.
It seems the fields property only allows mapping predefined fields like name, email, etc., but not the id field itself. Is it possible to configure better-auth to use custom ID column names like id_user? Thanks in advance for your help!
1 replies