Fix for undeleted games from library sources (#148)

* fix: casade delete for games and library sources

* fix: add bug workaround

* fix: lint
This commit is contained in:
DecDuck
2025-08-01 14:00:10 +10:00
committed by GitHub
parent b72e1ef7a4
commit 72c972a2a7
3 changed files with 20 additions and 1 deletions

View File

@ -0,0 +1,11 @@
-- DropForeignKey
ALTER TABLE "Game" DROP CONSTRAINT "Game_libraryId_fkey";
-- DropIndex
DROP INDEX "GameTag_name_idx";
-- CreateIndex
CREATE INDEX "GameTag_name_idx" ON "GameTag" USING GIST ("name" gist_trgm_ops(siglen=32));
-- AddForeignKey
ALTER TABLE "Game" ADD CONSTRAINT "Game_libraryId_fkey" FOREIGN KEY ("libraryId") REFERENCES "Library"("id") ON DELETE CASCADE ON UPDATE CASCADE;

View File

@ -36,7 +36,7 @@ model Game {
// These fields will not be optional in the next version
// Any game without a library ID will be assigned one at startup, based on the defaults
libraryId String?
library Library? @relation(fields: [libraryId], references: [id])
library Library? @relation(fields: [libraryId], references: [id], onDelete: Cascade, onUpdate: Cascade)
libraryPath String
collections CollectionEntry[]