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]>
12 lines
559 B
SQL
12 lines
559 B
SQL
-- 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;
|