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:
toanhoang
2026-08-04 06:41:13 -04:00
co-authored by Claude Sonnet 5
parent be47eb69d3
commit b702528e19
2 changed files with 13 additions and 2 deletions
@@ -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;