0.36.0 - The third parameter in Drizzle ORM becomes an array
Hello guys, I'm trying to setup Auth.js with Neon Postgres + Drizzle Adapter. The example given at think link: https://github.com/drizzle-team/drizzle-orm/releases/tag/0.36.0 for third param becomes an array is too basic for me to understand how do I change Auth.js schemas for accounts and sessions table to work with new version of Drizzle.
I'd very much appreciate if someone can change the following schema from object to array for third param i.e. setting up a compound primary key. Thank you.
export const accounts = pgTable(
"account",
{
userId: text("userId")
.notNull()
.references(() => users.id, { onDelete: "cascade" }),
type: text("type").$type<AdapterAccountType>().notNull(),
provider: text("provider").notNull(),
providerAccountId: text("providerAccountId").notNull(),
refresh_token: text("refresh_token"),
access_token: text("access_token"),
expires_at: integer("expires_at"),
token_type: text("token_type"),
scope: text("scope"),
id_token: text("id_token"),
session_state: text("session_state"),
},
(account) => ({
compoundKey: primaryKey({
columns: [account.provider, account.providerAccountId],
}),
})
)
GitHub
Release 0.36.0 ยท drizzle-team/drizzle-orm
This version of drizzle-orm requires [email protected] to enable all new features
New Features
The third parameter in Drizzle ORM becomes an array
The object API is still available but deprecate...
5 Replies
I have just submitted a PR to update the Auth JS docs for this.
Here's my schema, there are a few edits:
1) in your index.ts i changed it to set the casing to snake case
2) in your drizzle.config.ts i did the same
3) authjs schema:
You no longer need to pass in names for the fields:
you can find the PR here in the meantime: https://github.com/nextauthjs/next-auth/pull/12285
Thank you so much @ionztorm for the quick help, really appreciate it.
np I had the same problem about an hour ago ๐
Coming from the php background and learning React/Next, i find it so frustrating about the issues and setbacks in JS world, with laravel, Symfony I never found errors or missing docs in stable releases. Anyways not giving up ๐
nope never give up! I think in this case we are using 2 packages that are both in beta, so the docs will alwayas be a little behind until full release