Update your Prisma client to Lucia v2
Install the latest version of the Prisma adapter.
npm i @lucia-auth/adapter-prisma@latest
pnpm add @lucia-auth/adapter-prisma@latest
yarn add @lucia-auth/adapter-prisma@latest
Remove single use keys#
SQL#
Same for SQLite, PostgreSQL, and MySQL.
DELETE FROM auth_key
WHERE expires != null;
MongoDB#
// db.<collection_name>
db.authKey.deleteMany({
expires: { $ne: null }
});
Update AuthKey
model#
Remove Key(primary_key)
and Key(expires)
from the schema.
model AuthKey {
id String @id @unique
hashed_password String?
user_id String
auth_user AuthUser @relation(references: [id], fields: [user_id], onDelete: Cascade)
@@index([user_id])
@@map("auth_key")
}
Initialize adapter#
prisma()
is now a named export instead of a default export.
import { lucia } from "lucia";
import { prisma } from "@lucia-auth/adapter-prisma";
import { PrismaClient } from "@prisma/client";
const client = new PrismaClient();
// default values
const auth = lucia({
adapter: prisma(client, {
user: "authUser",
key: "authKey",
session: "authSession"
})
// ...
});
You can now rename the models as well. Without the second options
params, the adapter expects the default schema, which is different from the one required in v1.