Sam Bunger
08/26/2021, 6:25 PMprisma db push ?
Here is my schema:
model profiles {
id String @id
first_name String?
last_name String?
phone_number String @unique
phone_number_ref contacts[]
contacts_ref contacts[] @relation("contact_holder")
}
model contacts {
id Int @id
contact String?
contact_ref profiles? @relation(fields: [contact], references: [phone_number])
contact_holder String
contact_holder_ref profiles @relation("contact_holder", fields: [contact_holder], references: [id])
}
Every profile has an id and a phone_number. Each user in the profiles table will have each of their contacts on their phone put into contacts as individual rows. contact_holder_ref will always reference a user id in the profiles table. But a user’s contacts might may or may not reference another profile’s phone_number in the profiles table. Foreign key constraints are getting created by prisma that prevent me from adding phone numbers in contacts that don’t exist in profiles. Is there anything I can do to stop contacts_contact_fkey from getting created? Everything seems to work when I manually delete the constraint, but then I can’t run prisma db push again.cedric
08/26/2021, 6:26 PMSam Bunger
08/26/2021, 6:35 PMcedric
08/26/2021, 6:38 PMphone_number: PhoneNumber? and phone_number_id: String? )Sam Bunger
08/26/2021, 7:51 PMRyan
08/27/2021, 5:54 AM