-
Notifications
You must be signed in to change notification settings - Fork 856
Closed
Labels
type/docsDocumentation creation, updates or correctionsDocumentation creation, updates or corrections
Description
Bug description
In the docs with cockroachdb selected (https://www.prisma.io/docs/getting-started/setup-prisma/start-from-scratch/relational-databases/using-prisma-migrate-typescript-cockroachdb)
This is the example schema... which does not work The `autoincrement()` default function is defined only on BigInt fields on CockroachDB. Use sequence() if you want an autoincrementing Int field.
model Post {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
title String @db.VarChar(255)
content String?
published Boolean @default(false)
author User @relation(fields: [authorId], references: [id])
authorId Int
}
model Profile {
id Int @id @default(autoincrement())
bio String?
user User @relation(fields: [userId], references: [id])
userId Int @unique
}
model User {
id Int @id @default(autoincrement())
email String @unique
name String?
posts Post[]
profile Profile?
}
I found examples like below, but what is the correct way for a classic autoincrement with cockroachdb ?
model Question {
id String @id @default(cuid())
How to reproduce
Try the example schema with provider = "cockroachdb"
Expected behavior
Working autoincrementing id field.
Correct documentation.
Prisma information
Environment & setup
- OS:
- Database:
- Node.js version:
Prisma Version
Metadata
Metadata
Assignees
Labels
type/docsDocumentation creation, updates or correctionsDocumentation creation, updates or corrections