[GH-ISSUE #4926] --schema flag on CLI #10110

Closed
opened 2026-04-13 06:01:56 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @limegorilla on GitHub (Sep 26, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/4926

Is this suited for github?

  • Yes, this is suited for github

Coming from supabase I find myself missing the auth schema containing all my auth tables - like the drizzle-orm team, I find myself likening them to folders. I'd like to be able to put all my auth tables under their own schema for organisation.

Describe the solution you'd like

What I'd like to be able to do is to add --schema <NAME> to the generate command

Describe alternatives you've considered

The obvious one is to simply update the generated file once it's been created (my current workaround) but it would be nice if it was a step I didn't have to communicate to my team.

Additional context

This would obviously have to determine if your database provider supports this - aware that sqlite doesn't, and mysql treats schemas as effectively their own databases. To me this is built for postgres/mssql and it should error for other providers.

I'm happy to give this a go in a PR but wanted to make sure before I dedicate a weekend to it!

Drizzle ORM makes this easy:

- import { pgTable, ... } from "drizzle-orm"
+ import { pgSchema, ... } from "drizzle-orm"

+ const authSchema = pgSchema("auth")
  //    ^ would be inputted name + 'Schema'

- const user = pgTable("user", {
+ const user = authSchema.table("user", {
/// REST OF FILE ///

I'd have to look into keysley (not something I've used before) but also happy to give a go

Originally created by @limegorilla on GitHub (Sep 26, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/4926 ### Is this suited for github? - [x] Yes, this is suited for github ### Is your feature request related to a problem? Please describe. Coming from supabase I find myself missing the `auth` schema containing all my auth tables - [like the drizzle-orm team](https://orm.drizzle.team/docs/sql-schema-declaration#schemas), I find myself likening them to folders. I'd like to be able to put all my auth tables under their own schema for organisation. ### Describe the solution you'd like What I'd like to be able to do is to add `--schema <NAME>` to the `generate` command ### Describe alternatives you've considered The obvious one is to simply update the generated file once it's been created (my current workaround) but it would be nice if it was a step I didn't have to communicate to my team. ### Additional context This would obviously have to determine if your database provider supports this - aware that sqlite doesn't, and mysql treats schemas as effectively their own databases. To me this is built for postgres/mssql and it should error for other providers. I'm happy to give this a go in a PR but wanted to make sure before I dedicate a weekend to it! Drizzle ORM makes this easy: ```diff - import { pgTable, ... } from "drizzle-orm" + import { pgSchema, ... } from "drizzle-orm" + const authSchema = pgSchema("auth") // ^ would be inputted name + 'Schema' - const user = pgTable("user", { + const user = authSchema.table("user", { /// REST OF FILE /// ``` I'd have to look into keysley (not something I've used before) but also happy to give a go
GiteaMirror added the enhancementlocked labels 2026-04-13 06:01:56 -05:00
Author
Owner

@cfraz89 commented on GitHub (Oct 28, 2025):

I would like this too, I'm lazy so instead of making PR I'm just using running sed over the generated file for now:

sed -i -e '1s/pgTable/pgSchema/' -e '2i\\nexport const schema = pgSchema("auth");' -e 's/pgTable/schema.table/g' $AUTH_FILE
<!-- gh-comment-id:3456171828 --> @cfraz89 commented on GitHub (Oct 28, 2025): I would like this too, I'm lazy so instead of making PR I'm just using running sed over the generated file for now: ```sh sed -i -e '1s/pgTable/pgSchema/' -e '2i\\nexport const schema = pgSchema("auth");' -e 's/pgTable/schema.table/g' $AUTH_FILE ````
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#10110