Trying to write next-auth adapter
blahblahblahrober AKA @Dan Kochetov helped me get most of the way to having a next-auth adapter done but, in the couple weeks I waited for a review, I came back and now the SQLite migration is betraying me.
See video. Starting from a clean slate, it's saying
nothing to migrate
and, when I run tests against my db.sqlite
, I get back errors for no tables, kiddo
. Pretty confused; seems like I'm not pushing any schema somehow?
Pull request if you want to look at code: https://github.com/nextauthjs/next-auth/pull/7165
I'm working in ./packages/adapter-drizzle-sqlite
GitHub
feat(adapters): add Drizzle adapter by anthonyshew Β· Pull Request #...
βοΈ Reasoning
Introducing a drizzle-orm adapter!
With drizzle's increasing popularity, it's no surprise that there's a discussion for an adapter. This PR adds it.
π§’ Checklist
Documenta...
41 Replies
Wrong script used
Need to have generate:sqlite
And you have generate:mysql
But will improve warning for this case
It seems to be unclear at all whatβs happening
Oh, it still fails when it's right,
generate:sqlte
My b, I was doing science and forgot to switch that back in the video.so you are using
pnpm build
?
I'll clone your PR and will try to reproduceAnything that invokes the generator will do it.
pnpm generate-schema
will have the same behavior.Looking at your PR
generate-schema
has generate:mysql
script
So I guess the only right script is pnpm build
or
dev
I haven't pushed the correction yet.
got it
I'll ping you back after checking it locally
Gracias, papa.
Just pushed a cleanup some of my science.
so I made a fork
and run
pnpm generate-schema
if you are open for a call we can debug it on your end
but it seems to workBless ittttttttt.
That's just the worst outcome haha.
Thanks for taking the time, legend. I'll go figure my life out.
I can send you my laptop
And that's how Docker was born
wut kind is it
this needs more attention, I really wouldn't want to pay 100 bucks for 5000 users on Clerk π
How do I let Drizzle auto-assign a uuid? Or do I need to handle it in my code?
if it cannot be done via SQL, you can't for now
but we have a ticket for that
...ok, maybe we don't
let me create it
Gotcha, thanks.
One last one and then I think I'm going to be home free:
I'm trying to give the maintainers the option to have a
drizzle-adapter-all
if they want. Essentially, an adapter that will accept any of the SQL flavors. But I'm getting this. Is this me being dumb or will is drizzle freaking out because I have multiple clients (client flavors?) in one workspace?Would love to have this! for now I am always passing an empty id when inserting into a table like this:
Wow, fancy. I just did this. Is this naive? Using uuidv4 from the
uuid
npm package.That works too. I needed something reusable and automatic for use with multiple models.
I can suggest a bit of improvement here. May work
so no need for
id: ""
on insert
I didn't test a real query, but it should workwouldn't end up being a nullable column though?
only in types. As long as id will be always generated by customType
it means for insert function it can be nullable
but for migration kit will use primary key for this field
which is notNull on database layer
ah, I see, let me try it then!
and tbh, I would never think of using customType for this case π
it was smart
I don't know it was the first thing I grabbed for when I figured out that program generated default values were not yet supported βοΈ
tried it, but one downside seems to be that all of the places in my code where I took for granted that id is not null now seem to think it could be null π«’
Maybe try this
make it back notNull
but default true
and then you can put primary key back
it will still work
and
default: true
sounds much betterI think this is essentially what I tried in the past but couldn't get it to work, but let me try again!
Yeah, for some reason when I do it this way, it never seems to get to the
toDriver
method of the custom type
It seems like default: true
causes it to bypass toDriver
when the value is undefined, assuming that the database will take care of it?I'll check a code now
it shouldn't
because those are just types
yeah, you are right
if value is undefined orm will bypass toDriver, because already know, that the value is null/db default
but I don't think it should work this way
toDriver should always intercept insert values
i had the same thought... then https://github.com/drizzle-team/drizzle-orm/issues/556 may not even be needed...
It would be nice to have it, so you don't need to create customType
it would be nice to make it both work as expected π
will do that
thanks for you investigations in this part. Was super helpful!
anytime thank you too!
uhhh
this is an error text I'm seeing for the first time in my life
will need to investigate
Did you try things from this thread? https://github.com/microsoft/TypeScript/issues/42873
GitHub
The inferred type of "X" cannot be named without a reference to "Y"...
Bug Report π Search Terms inferred type cannot be named, symlink node_modules π Version & Regression Information I'm verifying the problem on the [email protected]. I've not tried older ...
Yeah, I definitely made a spooky one, huh. π
i tried a couple different things to no avail. I eventually decided to just drop the βallβ adapter since it barely makes sense to have anyway. Just pick the right flavor, duh.
Today I've learned a new word: "avail"
thanks @anthonyshew
yesterday it was "plethora"
this is awesome work!!