-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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(drizzle-adapter): custom database's tables naming strategy #8344
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
|
@skyf0l is attempting to deploy a commit to the authjs Team on Vercel. A member of the Team first needs to authorize it. |
Up? |
I'm in a similar boat, migrating from Prisma to Drizzle and about to copy my own DrizzleAdapter out to make these modifications. |
Hey @skyf0l, I'm wondering whether giving the option to use either one of |
Hey @nhedger, first it was to keep consistency with the Prima adapter, then to avoid renaming tables in my production database just because of an ORM switch in my main application. As the Drizzle adapter is new, I think it's a good idea to start keeping consistency between them all. Finally, even though some database table names are case insensitive, not all are (e.g. PlanetScale). In any case, the main goal is consistency :) (ATM, we use a fork of the Drizzle adapter to avoid renaming our tables.) |
I understand that; my reasoning was that some users may prefer to use a different case. For example, all my tables use If you personally don't need this, I'd fully understand if you did not want to invest time in it and can submit a PR of my own. |
Oh, I read it sideways, yes indeed your suggestion is definitely the best! |
Glad to hear; let me know if you need any assistance. |
+1 on what you both have said @nhedger @skyf0l , we have a project where the tables are in |
fa96b45
to
65aa467
Compare
I've synchronized my fork with the upstream 🚀 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Im not in actual power here to accept or reject those changes you've made, but wanted to make a small suggestion
You could create a small naming table like:
const names = {
snake_case: {
userId: "user_id",
...
},
camelCase: {
userId: "userId",
...
},
pascalCase: {
userId: "UserId",
...
}
}
and then instead of doing tedious trenary everywhere (which is also typo prone) you could use names[namingStrategy].<name>
e.g. names[namingStrategy].userId
In general this looks good to me, tests are still passing too! @balazsorban44 @ThangHuuVu we had something similar with another db adapter in the past, but I can't remember the details. I think technically this is good to go, yall okay with this generally? |
Btw see this PR that adds support for custom tables and seems to ahve a lot of overlap: #8561 |
I have no authority here but just want to chime in that I prefer the other PR over this one. I want to do snake_case but pluralize and I dont think this PR would support that. I assume future developers might want totally different names or a prefix for the table names. It would be better instead to just allow us to pass the schemas as options |
☕️ Reasoning
I'm migrating my database from Prisma to Drizzle, but I got a problem using drizzle adapter cause table names are different (camelCase vs PascalCase). So, I added an option to force the naming strategy 🚀
🧢 Checklist
🎫 Affected issues
Please scout and link issues that might be solved by this PR.
Fixes: INSERT_ISSUE_LINK_HERE
📌 Resources