Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add options object where you can specify a schema #11344

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jlvdh
Copy link

@jlvdh jlvdh commented Jul 7, 2024

☕️ Reasoning

The @auth/kysely-adapter currently depends on the tables to be configured in postgres. But it's good practice to add the tables in their own schema (eg auth.User, auth.Session, etc.) This PR would enable the configuration of a schema that is used for all the necessary tables by using: KyselyAdapter(db, {schemaName: "auth"})

Interested to hear if this type of feature would be eligible to merge in the project?

🧢 Checklist

  • Documentation
  • Tests
  • Ready to be merged

@jlvdh jlvdh requested a review from ndom91 as a code owner July 7, 2024 10:56
Copy link

vercel bot commented Jul 7, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
auth-docs ❌ Failed (Inspect) Aug 9, 2024 9:25am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
next-auth-docs ⬜️ Ignored (Inspect) Visit Preview Aug 9, 2024 9:25am

Copy link

vercel bot commented Jul 7, 2024

@jlvdh is attempting to deploy a commit to the authjs Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions bot added adapters Changes related to the core code concerning database adapters kysely labels Jul 7, 2024
@ndom91
Copy link
Member

ndom91 commented Jul 21, 2024

Yeah so in general we do something similar in most other adapters. Ideally we wouldn't have an implicit link between what you name something in your DB schema manually adn the name we expect in the kysely adapter code..

I'm not familiar with Kysely, but can you explicitly define the schemas and pass them to the Kysely instance? Like we do in the Drizzle adapter

@jlvdh
Copy link
Author

jlvdh commented Jul 22, 2024

@ndom91 Thanks for the reply.

Kysely doesn't seem to use models like Drizzle. In Kysely you write your own migrations. So passing the schema and table names would be in string format.

KyselyAdapter(db, {schemaName: "auth"})

Could simply be added using withSchema

ie: https://github.com/nextauthjs/next-auth/pull/11344/files#diff-8f2587157000f269c1784f539508271ebb924ca9b7f5a5fdccd02fe2682c56e5R70

For further customisation of the table names we could do something like:

KyselyAdapter(db, {schemaName: "auth", accountTable: "account", userTable: "user" .. etc })

@jlvdh
Copy link
Author

jlvdh commented Aug 9, 2024

Added tests and docs now too

feat: configure a schema for the tables

add docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
adapters Changes related to the core code concerning database adapters kysely
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants