More flexible schema creation for database adapters #3041

Open
opened 2026-03-13 10:35:47 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @boazpoolman on GitHub (Mar 13, 2026).

Is this suited for github?

  • Yes, this is suited for github

Is your feature request related to a problem? Please describe.

I've built a database adapter for Strapi CMS (https://github.com/strapi-community/plugin-better-auth). Now I'm looking to implement the createSchema method in order for Better Auth to dynamically update the Strapi schema once you install the two-factor plugin e.g.

However, while doing so, it seems that this system is designed to output a single schema file. However Strapi expects multiple schema files, one for each content type (table).

Describe the solution you'd like

I would like to have the ability, inside the createSchema method, to specify that I'll be using my own logic for writing the schema file(s). As of today, the createSchema method expects an object as the return value, specifying the contents and location of the schema file. Better Auth will then handle writing to that file. Because for my use case I like to write to multiple schema files I would like to opt-out of that file writing logic.

I understand that this can quickly become a breaking change which might not be desirable. However we could explore having multiple return types, maintaining backwards compatibility while supporting my use-case.

Describe alternatives you've considered

Currently I've worked around the issue by just returning true in the method. That will completely skip the schema file writing process. However that will show a false "Your schema is already up to date" output statement after the CLI finishes running. While in reality, I have just written all the required schema files myself.

Additional context

I'd be happy to contribute this feature if you we are aligned on the implementation specs. Let me know! Thanks for all you are doing in the ecosystem :)

Originally created by @boazpoolman on GitHub (Mar 13, 2026). ### Is this suited for github? - [x] Yes, this is suited for github ### Is your feature request related to a problem? Please describe. I've built a database adapter for Strapi CMS (https://github.com/strapi-community/plugin-better-auth). Now I'm looking to implement the [`createSchema` method](https://better-auth.com/docs/guides/create-a-db-adapter#createschema-optional) in order for Better Auth to dynamically update the Strapi schema once you install the two-factor plugin e.g. However, while doing so, it seems that this system is designed to output a single schema file. However Strapi expects multiple schema files, one for each content type (table). ### Describe the solution you'd like I would like to have the ability, inside the `createSchema` method, to specify that I'll be using my own logic for writing the schema file(s). As of today, the `createSchema` method expects an object as the return value, specifying the contents and location of the schema file. Better Auth will then handle writing to that file. Because for my use case I like to write to multiple schema files I would like to opt-out of that file writing logic. I understand that this can quickly become a breaking change which might not be desirable. However we could explore having multiple return types, maintaining backwards compatibility while supporting my use-case. ### Describe alternatives you've considered Currently I've worked around the issue by just returning `true` in the method. That will completely skip the schema file writing process. However that will show a false "Your schema is already up to date" output statement after the CLI finishes running. While in reality, I have just written all the required schema files myself. ### Additional context I'd be happy to contribute this feature if you we are aligned on the implementation specs. Let me know! Thanks for all you are doing in the ecosystem :)
GiteaMirror added the enhancement label 2026-03-13 10:35:47 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#3041