fix: change Assignment.assetItemId/licenseId FK onDelete to RESTRICT
Was implicitly SET NULL (Prisma default for nullable FK columns), inconsistent with employeeId's RESTRICT. Once a delete endpoint for AssetItem/License exists, SET NULL would silently null out historical Assignment rows on delete, erasing what was assigned and re-violating the assetItemId/licenseId XOR retroactively. No delete endpoint exists yet, so no real data was ever affected by the old behavior. Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
be47eb69d3
commit
b702528e19
@@ -398,9 +398,9 @@ model Assignment {
|
||||
employeeId String @map("employee_id") @db.Uuid
|
||||
employee Employee @relation(fields: [employeeId], references: [id])
|
||||
assetItemId String? @map("asset_item_id") @db.Uuid
|
||||
assetItem AssetItem? @relation(fields: [assetItemId], references: [id])
|
||||
assetItem AssetItem? @relation(fields: [assetItemId], references: [id], onDelete: Restrict)
|
||||
licenseId String? @map("license_id") @db.Uuid
|
||||
license License? @relation(fields: [licenseId], references: [id])
|
||||
license License? @relation(fields: [licenseId], references: [id], onDelete: Restrict)
|
||||
assignedAt DateTime @default(now()) @map("assigned_at") @db.Timestamptz(6)
|
||||
returnedAt DateTime? @map("returned_at") @db.Timestamptz(6)
|
||||
signedAt DateTime? @map("signed_at") @db.Timestamptz(6)
|
||||
|
||||
Reference in New Issue
Block a user