Hey guys, last time we ran `npx prisma format` it ...
# orm-help
m
Hey guys, last time we ran
npx prisma format
it automatically added
@unique
to some of our foreign key columns. Whilst this might be beneficial for some, this automatic addition of directive prohibits us from re-using our featured image across Recipes.
r
@Mark 👋 If it’s a 1-1 relation, it might do that, which is what you would want ideally.
Could you share an example where it does this? I would like to check.
1
m
Copy code
model Recipe {
  id          String    @id @default(cuid())
  slug        String    @unique
  createdAt   DateTime  @default(now())
  updatedAt   DateTime  @updatedAt

  featuredImage   Image?  @relation(fields: [featuredImageId], references: [id])
  featuredImageId String?
}

model Image {
  id          String @id @default(cuid())

  title    String
  altText  String
  mimeType String
  url      String


  height Int
  width  Int

  recipe       Recipe?
}
I think I get it, it’s because recipe is singular, which makes it a 1-1 relation. So you would want it to be unique
💯 1
r
Yup that’s the reason.
👍 1