PrismaP
Prisma11mo ago
12 replies
dotEXE

How to update Prisma @unique

Hello,
So I started a new NextJS project.
I did this:
model Post {
  id        String   @id @default(cuid())
  title     String
  slug      String
  content   String
  updatedAt DateTime @updatedAt
  createdAt DateTime @default(now())
}

Then I added to slug @unique
But when I tried to do
const post = await prisma.post.findUnique({
        where: {
            slug
        }
    });

It gave me an error : Invalid prisma.user.findUnique() invocation:

How do I apply the new @unique? the npx prisma db push did not work
Was this page helpful?