Dev__
06/09/2021, 12:51 PMSET NULL inside the schema.prisma? Is the only way of doing this an optional relation?Ryan
06/09/2021, 12:54 PMDev__
06/09/2021, 12:56 PMDev__
06/09/2021, 1:14 PM// schema
model Buyer {
...
/// @onDelete(SET_NULL)
quotations Quotation[]
}
model Quotation {
...
buyer Buyer @relation(fields: [buyerId], references: [id])
}
// code
const prismaDelete = new PrismaDelete(this.prisma);
await prismaDelete.onDelete({
model: 'Buyer',
where: {
buyerId: {
in: ids
}
}
});
I am still getting an errorDev__
06/09/2021, 1:16 PMRyan
06/09/2021, 1:17 PMAhmed
06/09/2021, 1:26 PMWhere:{id:{in:ids}}Dev__
06/09/2021, 1:30 PMDev__
06/09/2021, 1:33 PMawait prismaDelete.onDelete({
model: 'Buyer',
where: {
id: {
in: ids
}
}
});Ahmed
06/09/2021, 1:37 PMDev__
06/09/2021, 1:46 PMnull 🤔Ahmed
06/09/2021, 1:51 PM// schema
model Buyer {
...
Delete all relation when delete
/// @onDelete(CASCADE)
quotations Quotation[]
}
model Quotation {
...
//or make this relation optional
buyer Buyer? @relation(fields: [buyerId], references: [id])
}Dev__
06/09/2021, 1:52 PMAhmed
06/09/2021, 1:53 PMDev__
06/09/2021, 1:54 PMSET_NULL will still delete the relation records. So i dont need to use it thenAhmed
06/09/2021, 1:56 PMDev__
06/09/2021, 1:56 PMAhmed
06/09/2021, 1:58 PMDev__
06/09/2021, 2:00 PMAhmed
06/09/2021, 2:00 PMAhmed
06/09/2021, 2:01 PMDev__
06/09/2021, 2:10 PMDev__
06/09/2021, 2:10 PMDev__
06/09/2021, 2:11 PMmodel Quotation {
id String @id @db.VarChar(255)
buyerId String @db.VarChar(255)
buyer Buyer? @relation(fields: [buyerId], references: [id])
}
/// @onDelete(SET_NULL)
quotations Quotation[]Ahmed
06/09/2021, 2:14 PMDev__
06/09/2021, 2:18 PMDev__
06/09/2021, 2:18 PMDaniel Norman
Dev__
06/09/2021, 3:25 PMpush. Will try again with deleting the database and running a fresh push