[GH-ISSUE #4368] Passkey plugin creates field credential_i_d #9915

Closed
opened 2026-04-13 05:43:52 -05:00 by GiteaMirror · 4 comments
Owner

Originally created by @isaacwasserman on GitHub (Sep 2, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/4368

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. Use drizzle db adapter
  2. Add the passkeys plugin
  3. Generate migration

Current vs. Expected behavior

The generated schema should have a table passkeys with a column credential_id. Instead, it creates a column credential_i_d.

This doesn't cause any huge issues, but it seems like a mistake as it does not follow the convention used by other generated tables.

What version of Better Auth are you using?

1.3.7

System info

System:
    OS: macOS 15.0.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 132.36 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Browsers:
    Chrome: 139.0.7258.155
    Safari: 18.0.1

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

Backend

Additional context

No response

Originally created by @isaacwasserman on GitHub (Sep 2, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/4368 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce 1. Use drizzle db adapter 2. Add the passkeys plugin 3. Generate migration ### Current vs. Expected behavior The generated schema should have a table `passkeys` with a column `credential_id`. Instead, it creates a column `credential_i_d`. This doesn't cause any huge issues, but it seems like a mistake as it does not follow the convention used by other generated tables. ### What version of Better Auth are you using? 1.3.7 ### System info ```bash System: OS: macOS 15.0.1 CPU: (10) arm64 Apple M1 Pro Memory: 132.36 MB / 16.00 GB Shell: 5.9 - /bin/zsh Browsers: Chrome: 139.0.7258.155 Safari: 18.0.1 ``` ### Which area(s) are affected? (Select all that apply) Backend ### Additional context _No response_
GiteaMirror added the locked label 2026-04-13 05:43:52 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Sep 2, 2025):

Hi @isaacwasserman! I'm Dosu and I’m helping the better-auth team.

This happens because the passkey plugin defines the field as credentialID (camelCase), and the Drizzle adapter's schema generator converts camelCase to snake_case by splitting every uppercase letter, resulting in credential_i_d instead of the conventional credential_id source. This isn't hardcoded—it's an automatic transformation that can affect other fields with acronyms or compound words.

In Better Auth v1.3.7, this behavior is present by default. However, newer versions of Better Auth (after July 2025) added a camelCase option to the Drizzle adapter config, which lets you disable this conversion and keep camelCase names as-is during schema generation source. If you want to avoid the credential_i_d naming, you can upgrade and set camelCase: true in your Drizzle adapter config. Otherwise, you’ll need to manually adjust the generated schema to match your preferred naming convention.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

<!-- gh-comment-id:3246913551 --> @dosubot[bot] commented on GitHub (Sep 2, 2025): <!-- Greeting --> Hi @isaacwasserman! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the better-auth team. <!-- Answer --> This happens because the passkey plugin defines the field as `credentialID` (camelCase), and the Drizzle adapter's schema generator converts camelCase to snake_case by splitting every uppercase letter, resulting in `credential_i_d` instead of the conventional `credential_id` [source](https://github.com/better-auth/better-auth/blob/23daf79a427ea987a4d94d0431e0fb306d26d464/packages/better-auth/src/plugins/passkey/index.ts). This isn't hardcoded—it's an automatic transformation that can affect other fields with acronyms or compound words. In Better Auth v1.3.7, this behavior is present by default. However, newer versions of Better Auth (after July 2025) added a `camelCase` option to the Drizzle adapter config, which lets you disable this conversion and keep camelCase names as-is during schema generation [source](https://github.com/better-auth/better-auth/pull/2550). If you want to avoid the `credential_i_d` naming, you can upgrade and set `camelCase: true` in your Drizzle adapter config. Otherwise, you’ll need to manually adjust the generated schema to match your preferred naming convention. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/15d0d7c2-0253-4035-852f-cb9502a1450c?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/15d0d7c2-0253-4035-852f-cb9502a1450c?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/15d0d7c2-0253-4035-852f-cb9502a1450c?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/15d0d7c2-0253-4035-852f-cb9502a1450c?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/15d0d7c2-0253-4035-852f-cb9502a1450c?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/15d0d7c2-0253-4035-852f-cb9502a1450c?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/15d0d7c2-0253-4035-852f-cb9502a1450c?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/4368)
Author
Owner

@isaacwasserman commented on GitHub (Sep 2, 2025):

Regarding Dosu's reply, I suppose the problem isn't that credential_i_d is wrong, but instead that credentialID is wrong, as other tables use a lowercase d for Id.

<!-- gh-comment-id:3246920349 --> @isaacwasserman commented on GitHub (Sep 2, 2025): Regarding Dosu's reply, I suppose the problem isn't that `credential_i_d` is wrong, but instead that `credentialID` is wrong, as other tables use a lowercase `d` for `Id`.
Author
Owner

@himself65 commented on GitHub (Sep 3, 2025):

Thanks, I will try add a test for this and see if we have such issue

<!-- gh-comment-id:3250643985 --> @himself65 commented on GitHub (Sep 3, 2025): Thanks, I will try add a test for this and see if we have such issue
Author
Owner

@julen commented on GitHub (Sep 3, 2025):

We've encountered similar issues with acronyms in field names causing DB adapter problems, as seen in #4198 with Kysely. While special-casing could work, it feels like a workaround rather than addressing the root cause — as @isaacwasserman noted, the underlying issue is inconsistency when naming fields.

Perhaps better-auth could consider enforcing strict camel case across all DB fields instead. This would eliminate the need for code handling special-cases, would provide consistent behavior across different DB adapters, and would prevent similar issues from arising with future field additions. Anyway, just my 2c.

<!-- gh-comment-id:3250792740 --> @julen commented on GitHub (Sep 3, 2025): We've encountered similar issues with acronyms in field names causing DB adapter problems, as seen in #4198 with Kysely. While special-casing could work, it feels like a workaround rather than addressing the root cause — as @isaacwasserman noted, the underlying issue is inconsistency when naming fields. Perhaps better-auth could consider enforcing strict camel case across all DB fields instead. This would eliminate the need for code handling special-cases, would provide consistent behavior across different DB adapters, and would prevent similar issues from arising with future field additions. Anyway, just my 2c.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#9915