feat: rework developer/publisher system

This commit is contained in:
DecDuck
2025-05-10 11:59:56 +10:00
parent ac355918ed
commit 90277653cb
12 changed files with 132 additions and 247 deletions

View File

@ -0,0 +1,76 @@
/*
Warnings:
- You are about to drop the `CompanyGameRelation` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `Developer` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `Publisher` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `_DeveloperToGame` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `_GameToPublisher` table. If the table is not empty, all the data it contains will be lost.
*/
-- DropForeignKey
ALTER TABLE "CompanyGameRelation" DROP CONSTRAINT "CompanyGameRelation_companyId_fkey";
-- DropForeignKey
ALTER TABLE "CompanyGameRelation" DROP CONSTRAINT "CompanyGameRelation_gameId_fkey";
-- DropForeignKey
ALTER TABLE "_DeveloperToGame" DROP CONSTRAINT "_DeveloperToGame_A_fkey";
-- DropForeignKey
ALTER TABLE "_DeveloperToGame" DROP CONSTRAINT "_DeveloperToGame_B_fkey";
-- DropForeignKey
ALTER TABLE "_GameToPublisher" DROP CONSTRAINT "_GameToPublisher_A_fkey";
-- DropForeignKey
ALTER TABLE "_GameToPublisher" DROP CONSTRAINT "_GameToPublisher_B_fkey";
-- DropTable
DROP TABLE "CompanyGameRelation";
-- DropTable
DROP TABLE "Developer";
-- DropTable
DROP TABLE "Publisher";
-- DropTable
DROP TABLE "_DeveloperToGame";
-- DropTable
DROP TABLE "_GameToPublisher";
-- CreateTable
CREATE TABLE "_developers" (
"A" TEXT NOT NULL,
"B" TEXT NOT NULL,
CONSTRAINT "_developers_AB_pkey" PRIMARY KEY ("A","B")
);
-- CreateTable
CREATE TABLE "_publishers" (
"A" TEXT NOT NULL,
"B" TEXT NOT NULL,
CONSTRAINT "_publishers_AB_pkey" PRIMARY KEY ("A","B")
);
-- CreateIndex
CREATE INDEX "_developers_B_index" ON "_developers"("B");
-- CreateIndex
CREATE INDEX "_publishers_B_index" ON "_publishers"("B");
-- AddForeignKey
ALTER TABLE "_developers" ADD CONSTRAINT "_developers_A_fkey" FOREIGN KEY ("A") REFERENCES "Company"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "_developers" ADD CONSTRAINT "_developers_B_fkey" FOREIGN KEY ("B") REFERENCES "Game"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "_publishers" ADD CONSTRAINT "_publishers_A_fkey" FOREIGN KEY ("A") REFERENCES "Company"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "_publishers" ADD CONSTRAINT "_publishers_B_fkey" FOREIGN KEY ("B") REFERENCES "Game"("id") ON DELETE CASCADE ON UPDATE CASCADE;

View File

@ -17,8 +17,6 @@ model Game {
mName String // Name of game
mShortDescription String // Short description
mDescription String // Supports markdown
mDevelopers Developer[]
mPublishers Publisher[]
mReleased DateTime // When the game was released
mReviewCount Int
@ -33,10 +31,12 @@ model Game {
versions GameVersion[]
libraryBasePath String @unique // Base dir for all the game versions
collections CollectionEntry[]
saves SaveSlot[]
screenshots Screenshot[]
companyRelations CompanyGameRelation[]
collections CollectionEntry[]
saves SaveSlot[]
screenshots Screenshot[]
developers Company[] @relation(name: "developers")
publishers Company[] @relation(name: "publishers")
@@unique([metadataSource, metadataId], name: "metadataKey")
}
@ -117,62 +117,12 @@ model Company {
mBannerObjectId String
mWebsite String
gameRelations CompanyGameRelation[]
developed Game[] @relation(name: "developers")
published Game[] @relation(name: "publishers")
@@unique([metadataSource, metadataId], name: "metadataKey")
}
model CompanyGameRelation {
companyId String
company Company @relation(fields: [companyId], references: [id], onDelete: Cascade)
gameId String
game Game @relation(fields: [gameId], references: [id], onDelete: Cascade)
// what the company did for the game
developer Boolean @default(false)
publisher Boolean @default(false)
@@unique([companyId, gameId], name: "companyGame")
}
model Developer {
id String @id @default(uuid())
metadataSource MetadataSource
metadataId String
metadataOriginalQuery String
mName String
mShortDescription String
mDescription String
mLogo String
mBanner String
mWebsite String
games Game[]
@@unique([metadataSource, metadataId, metadataOriginalQuery], name: "metadataKey")
}
model Publisher {
id String @id @default(uuid())
metadataSource MetadataSource
metadataId String
metadataOriginalQuery String
mName String
mShortDescription String
mDescription String
mLogo String
mBanner String
mWebsite String
games Game[]
@@unique([metadataSource, metadataId, metadataOriginalQuery], name: "metadataKey")
}
model ObjectHash {
id String @id
hash String