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
@@ -0,0 +1,11 @@
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "assignments" DROP CONSTRAINT "assignments_asset_item_id_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "assignments" DROP CONSTRAINT "assignments_license_id_fkey";
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "assignments" ADD CONSTRAINT "assignments_asset_item_id_fkey" FOREIGN KEY ("asset_item_id") REFERENCES "asset_items"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "assignments" ADD CONSTRAINT "assignments_license_id_fkey" FOREIGN KEY ("license_id") REFERENCES "licenses"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
Reference in New Issue
Block a user