feat(db): preserve agent sessions on asset deletion by setting onDelete to SetNull

This commit is contained in:
yiling
2026-07-29 15:42:45 +08:00
parent f3d42cd0ce
commit cdc344ab7a
4 changed files with 73 additions and 2 deletions
@@ -0,0 +1,5 @@
-- DropForeignKey
ALTER TABLE "agent_sessions" DROP CONSTRAINT "agent_sessions_asset_id_fkey";
-- AddForeignKey
ALTER TABLE "agent_sessions" ADD CONSTRAINT "agent_sessions_asset_id_fkey" FOREIGN KEY ("asset_id") REFERENCES "assets"("id") ON DELETE SET NULL ON UPDATE CASCADE;