The field "id" does not exist in the "verification" schema
Hey guys, I'm trying to get Better Auth working with Directus, a headless CMS system. I'm having to hack around a little by manually creating the tables that there isn't an analog in Directus, and am having an issue with the verification table, which outputs
Introspecting my postgres db, this is the table that I've created;
Not sure what's wrong- it's complaining about the ID. How is the id created? Is it expecting it to be a uuid?
14 Replies
Is there a specific action which you did before seeing this error?
I don't believe this actually an error due to your Drizzle schema.
Yeah, I created the table in the drizzle studio. The error was occurring when I tried to use the social provider login method.
Directus has some of the tables already set up since it implements its own auth methods, but it's relatively primitive and doesn't go nearly as in depth, so I wanted to tack betterauth onto it and use it for client authentication. It's gotta leverage the directus methods since it uses the access token to handle permissions for requesting data via the SDK though.
You created the table straight in drizzle studio?
So is this code inside your drizzle schema?
@rhys
I created the table via the drizzle studio, and then introspected it (I've got some funky stuff going on which would be destroyed if i migrated, hence why I opted to use the studio)
Oh, interesting.
It's uhh, certainly not ideal 😅
Did you use any database hooks in your auth config?
No, none.
Directus uses knex and might have some hooks under the hood for the user table, but the verification table's totally divorced from it currently since there isn't a directus equivalent to my understanding
Do you think I can see your auth & your drizzle schema files?
Of course!
We currently don't support using custom
id
fields.
In your auth config, you're trying to rename id
in session
model to token
, which we don't support yet.
This is likely the cause. @rhysAhhh yeah, I can see that. I've removed that, but it's still returning the same issue.
In your Better auth config, you're passing the schema incorrectly for the drizzleAdapter.
You should pass your entire Drizzle schema from schema.ts in.
@rhys
You're absolutely right! Thanks so much.