Hello everyone :slightly_smiling_face: I need a li...
# prisma-migrate
m
Hello everyone 🙂 I need a little bit of help for some conception issue. Let me present you a simplified version of my schema :
Copy code
generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["referentialActions"]
}

datasource db {
  provider = "mysql"
  url      = env("DATABASE_URL")
}

model Link {
  id                  String            @id @default(uuid())
  href                String
  content             String
  androidLinkSite     Site?             @relation("androidLinkToSite")
  iOSLinkSite         Site?             @relation("iOSLinkToSite")
}

model Site {
  id                     String            @id @default(uuid())
  iOSLink                Link?             @relation("iOSLinkToSite", fields: [iOSLinkId], references: [id])
  iOSLinkId              String?
  androidLink            Link?             @relation("androidLinkToSite", fields: [androidLinkId], references: [id])
  androidLinkId          String?
}
I have
sites
that have different sorts of
links
. In this case an
androidLink
and an
iOSLink
(both are 1-to-1 relationship). What I want to do is when a
site
is deleted, it should delete also it
androidLink
and
iOSLink
. How can I archieve this ? One solution can be moving foreign keys from Site to Link and using cascade delete on Link . But it's seems ugly to me as it will polluate my Link table with many potentially unnecessary columns