Prisma user id is Int but referenced as string

When I generate the schema with Prisma the user id in user modal is from type Int. But the references of the id is defined as string. I get the error: Error parsing attribute "@relation": The type of the field userId in the model Session is not matching the type of the referenced field id in model User.Prisma
"@prisma/client": "^6.18.0",
"prisma": "^6.18.0",
"@prisma/client": "^6.18.0",
"prisma": "^6.18.0",
npx @better-auth/cli generate --config ./app/utils/auth.server.ts --output ./prisma/schema.prisma Output:
model User {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
email String @unique
name String?
emailVerified Boolean @default(false)
image String?
updatedAt DateTime @default(now()) @updatedAt
first_name String?
last_name String?
sessions Session[]
accounts Account[]

@@map("user")
}

model Session {
id String @id
expiresAt DateTime
token String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
ipAddress String?
userAgent String?
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)

@@unique([token])
@@map("session")
}
}
model User {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
email String @unique
name String?
emailVerified Boolean @default(false)
image String?
updatedAt DateTime @default(now()) @updatedAt
first_name String?
last_name String?
sessions Session[]
accounts Account[]

@@map("user")
}

model Session {
id String @id
expiresAt DateTime
token String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
ipAddress String?
userAgent String?
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)

@@unique([token])
@@map("session")
}
}
1 Reply
zgy
zgyOP2d ago
looks like I used a older cli version

Did you find this page helpful?