[GH-ISSUE #4199] [OIDC] Schema cannot be customized #9862

Closed
opened 2026-04-13 05:38:32 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @julen on GitHub (Aug 24, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/4199

We use plural names for table names, and when using the OIDC plugin we noticed all queries were failing against it.

2025-08-24T12:46:39.088Z INFO [Better Auth]: [Kysely Adapter] #14 [2/4] create (Parsed Input): {
  model: 'oauthApplication',
  data: {
    name: 'aaaa',
    metadata: null,
    clientId: 'xUZeuIEyKoTwMySMpWQBZlkhZLNhiJkM',
    clientSecret: 'MdSfgkGbqhiICxgrrZgVgjYKdUSfddbj',
    redirectURLs: 'http://localhost:3000',
    type: 'web',
    disabled: false,
    userId: 'UaEaZ9MUY7bN6TbDJQYHeiOGOlcnFerb',
    createdAt: 2025-08-24T12:46:39.087Z,
    updatedAt: 2025-08-24T12:46:39.087Z,
    id: 'H8niOgbQWLw1vqvOdFICzXqatwQQ1s6x'
  }
}
# SERVER_ERROR:  error: relation "oauth_application" does not exist

We see the plugin is indeed missing the ability to merge custom schemas, and we expect it so support it similar to e.g. the two-factor plugin.

Originally created by @julen on GitHub (Aug 24, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/4199 We use plural names for table names, and when using the OIDC plugin we noticed all queries were failing against it. ```sh 2025-08-24T12:46:39.088Z INFO [Better Auth]: [Kysely Adapter] #14 [2/4] create (Parsed Input): { model: 'oauthApplication', data: { name: 'aaaa', metadata: null, clientId: 'xUZeuIEyKoTwMySMpWQBZlkhZLNhiJkM', clientSecret: 'MdSfgkGbqhiICxgrrZgVgjYKdUSfddbj', redirectURLs: 'http://localhost:3000', type: 'web', disabled: false, userId: 'UaEaZ9MUY7bN6TbDJQYHeiOGOlcnFerb', createdAt: 2025-08-24T12:46:39.087Z, updatedAt: 2025-08-24T12:46:39.087Z, id: 'H8niOgbQWLw1vqvOdFICzXqatwQQ1s6x' } } # SERVER_ERROR: error: relation "oauth_application" does not exist ``` We see the plugin is indeed [missing the ability to merge custom schemas](https://github.com/better-auth/better-auth/blob/4696b9e7ec02a061af5473a414a99cbdb3bb67f8/packages/better-auth/src/plugins/oidc-provider/index.ts#L1478), and we expect it so support it similar to e.g. [the two-factor plugin](https://github.com/better-auth/better-auth/blob/4696b9e7ec02a061af5473a414a99cbdb3bb67f8/packages/better-auth/src/plugins/two-factor/index.ts#L359).
GiteaMirror added the locked label 2026-04-13 05:38:32 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Aug 24, 2025):

You're right—the OIDC plugin doesn't currently support customizing or merging table names or schemas. It uses hardcoded singular model names like oauthApplication, which causes errors if your database uses pluralized table names (e.g., oauth_applications) source.

In contrast, the two-factor plugin supports schema customization by merging its default schema with user-provided overrides using a mergeSchema pattern source. This lets you specify custom table and field names in your config.

To enable schema customization in the OIDC plugin, it would need to adopt a similar approach—exposing a schema option and merging it with the defaults, then using those names in all adapter calls. Until that's implemented, your options are to rename your tables to match the plugin's expectations, patch the plugin locally, or customize your adapter to map the expected names to your actual tables.

If you want to see how others have handled similar issues, check out this discussion about pluralization and schema references. If you need guidance on patching the plugin or want to discuss a possible implementation, let me know!

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:3218087022 --> @dosubot[bot] commented on GitHub (Aug 24, 2025): <!-- Answer --> You're right—the OIDC plugin doesn't currently support customizing or merging table names or schemas. It uses hardcoded singular model names like `oauthApplication`, which causes errors if your database uses pluralized table names (e.g., `oauth_applications`) [source](https://github.com/better-auth/better-auth/blob/8c23eb07396478a51b4dc7de669c010cdadc5479/packages/better-auth/src/plugins/oidc-provider/index.ts). In contrast, the two-factor plugin supports schema customization by merging its default schema with user-provided overrides using a `mergeSchema` pattern [source](https://github.com/better-auth/better-auth/blob/8c23eb07396478a51b4dc7de669c010cdadc5479/packages/better-auth/src/plugins/two-factor/index.ts). This lets you specify custom table and field names in your config. To enable schema customization in the OIDC plugin, it would need to adopt a similar approach—exposing a `schema` option and merging it with the defaults, then using those names in all adapter calls. Until that's implemented, your options are to rename your tables to match the plugin's expectations, patch the plugin locally, or customize your adapter to map the expected names to your actual tables. If you want to see how others have handled similar issues, check out [this discussion about pluralization and schema references](https://github.com/better-auth/better-auth/issues/3069). If you need guidance on patching the plugin or want to discuss a possible implementation, let me know! <!-- 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/5980302a-ee4d-4878-8b31-99fa6cce6938?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/5980302a-ee4d-4878-8b31-99fa6cce6938?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/5980302a-ee4d-4878-8b31-99fa6cce6938?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/5980302a-ee4d-4878-8b31-99fa6cce6938?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/5980302a-ee4d-4878-8b31-99fa6cce6938?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/5980302a-ee4d-4878-8b31-99fa6cce6938?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/5980302a-ee4d-4878-8b31-99fa6cce6938?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/4199)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#9862