@@ -54,7 +54,7 @@ import {
5454} from " drizzle-orm/pg-core"
5555import postgres from " postgres"
5656import { drizzle } from " drizzle-orm/postgres-js"
57- import type { AdapterAccountType } from " @ auth/core /adapters"
57+ import type { AdapterAccountType } from " next- auth/adapters"
5858
5959const connectionString = " postgres://postgres:postgres@localhost:5432/drizzle"
6060const pool = postgres (connectionString , { max: 1 })
@@ -130,7 +130,7 @@ import {
130130} from " drizzle-orm/mysql-core"
131131import mysql from " mysql2/promise"
132132import { drizzle } from " drizzle-orm/mysql2"
133- import type { AdapterAccountType } from " @ auth/core /adapters"
133+ import type { AdapterAccountType } from " next- auth/adapters"
134134
135135export const connection = await mysql .createConnection ({
136136 host: " host" ,
@@ -209,7 +209,7 @@ If you want to modify the schema or add additional fields, you can use the follo
209209import { integer , sqliteTable , text , primaryKey } from " drizzle-orm/sqlite-core"
210210import { createClient } from " @libsql/client"
211211import { drizzle } from " drizzle-orm/libsql"
212- import type { AdapterAccountType } from " @ auth/core /adapters"
212+ import type { AdapterAccountType } from " next- auth/adapters"
213213
214214const client = createClient ({
215215 url: " DATABASE_URL" ,
@@ -328,6 +328,30 @@ app.use(
328328</Code.Express >
329329</Code >
330330
331+ #### Passing your own Schemas
332+
333+ If you want to use your own tables, you can pass them as a second argument to ` DrizzleAdapter ` .
334+
335+ - The ` sessionsTable ` is optional and only required if you're using the database session strategy.
336+ - The ` verificationTokensTable ` is optional and only required if you're using a Magic Link provider.
337+
338+ ``` ts filename="auth.ts"
339+ import NextAuth from " next-auth"
340+ import Google from " next-auth/providers/google"
341+ import { DrizzleAdapter } from " @auth/drizzle-adapter"
342+ import { db , accounts , sessions , users , verificationTokens } from " ./schema"
343+
344+ export const { handlers, auth } = NextAuth ({
345+ adapter: DrizzleAdapter (db , {
346+ usersTable: users ,
347+ accountsTable: accounts ,
348+ sessionsTable: sessions ,
349+ verificationTokensTable: verificationTokens ,
350+ }),
351+ providers: [Google ],
352+ })
353+ ```
354+
331355### Migrating your database
332356
333357With your schema now described in your code, you'll need to migrate your database to your schema. An example ` migrate.ts ` file looks like this. For more information, check out Drizzle's migration [ quick start guide] ( https://orm.drizzle.team/docs/migrations ) .
0 commit comments