[GH-ISSUE #2668] [BUG] Id in every tables (primary keys) cannot be renamed. #9292

Closed
opened 2026-04-13 04:43:08 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @MarkLee425 on GitHub (May 16, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/2668

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. Add fields in user
  2. try to rename id (primary key of user)
  3. Object literal may only specify known properties, and 'id' does not exist in type 'Partial<Record<"createdAt" | "updatedAt" | "providerId" | "accountId" | "userId" | "password" | "scope" | "refreshToken" | "accessToken" | "idToken" | "accessTokenExpiresAt" | "refreshTokenExpiresAt", string>>

Current vs. Expected behavior

Current:
Object literal may only specify known properties, and 'id' does not exist in type 'Partial<Record<"createdAt" | "updatedAt" | "providerId" | "accountId" | "userId" | "password" | "scope" | "refreshToken" | "accessToken" | "idToken" | "accessTokenExpiresAt" | "refreshTokenExpiresAt", string>>

Expected:
id: 'user_id' // for example

What version of Better Auth are you using?

1.2.7

Provide environment information

- OS: [MacOS 15.5]
- Browser: [Chrome]

Which area(s) are affected? (Select all that apply)

Types, Backend

Auth config (if applicable)

import { betterAuth } from "better-auth"
export const auth = betterAuth({
  user: {
     fields: {
        id: 'user_id' // Have error, mentioned above
     }
  }
});

Additional context

No response

Originally created by @MarkLee425 on GitHub (May 16, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/2668 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce 1. Add fields in user 2. try to rename id (primary key of user) 3. `Object literal may only specify known properties, and 'id' does not exist in type 'Partial<Record<"createdAt" | "updatedAt" | "providerId" | "accountId" | "userId" | "password" | "scope" | "refreshToken" | "accessToken" | "idToken" | "accessTokenExpiresAt" | "refreshTokenExpiresAt", string>>` ### Current vs. Expected behavior Current: `Object literal may only specify known properties, and 'id' does not exist in type 'Partial<Record<"createdAt" | "updatedAt" | "providerId" | "accountId" | "userId" | "password" | "scope" | "refreshToken" | "accessToken" | "idToken" | "accessTokenExpiresAt" | "refreshTokenExpiresAt", string>>` Expected: id: 'user_id' // for example ### What version of Better Auth are you using? 1.2.7 ### Provide environment information ```bash - OS: [MacOS 15.5] - Browser: [Chrome] ``` ### Which area(s) are affected? (Select all that apply) Types, Backend ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" export const auth = betterAuth({ user: { fields: { id: 'user_id' // Have error, mentioned above } } }); ``` ### Additional context _No response_
GiteaMirror added the locked label 2026-04-13 04:43:08 -05:00
Author
Owner

@astralarya commented on GitHub (Jun 2, 2025):

Looking at the source code, it appears to be intentional.

04695a7c5b/packages/better-auth/src/types/options.ts (L292)

However, I wonder if this is necessary, as I would also like to be able to rename the primary key columns.

<!-- gh-comment-id:2928344405 --> @astralarya commented on GitHub (Jun 2, 2025): Looking at the source code, it appears to be intentional. https://github.com/better-auth/better-auth/blob/04695a7c5b48391efaff21d3065ebc2832f2150f/packages/better-auth/src/types/options.ts#L292 However, I wonder if this is necessary, as I would also like to be able to rename the primary key columns.
Author
Owner

@astralarya commented on GitHub (Jun 17, 2025):

@Kinfe123, I see you closed this as completed, but it seems like it is still not possible to change the id column name. Tested on 1.2.9.

I looked at the relevant lines in the main branch, and it seems like the necessary changes haven't actually been made.

<!-- gh-comment-id:2978717330 --> @astralarya commented on GitHub (Jun 17, 2025): @Kinfe123, I see you closed this as completed, but it seems like it is still not possible to change the id column name. Tested on 1.2.9. I looked at the relevant lines in the main branch, and it seems like the necessary changes haven't actually been made.
Author
Owner

@mmolina-wortise commented on GitHub (Jul 31, 2025):

Any new about it?

<!-- gh-comment-id:3141643379 --> @mmolina-wortise commented on GitHub (Jul 31, 2025): Any new about it?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#9292