drop/server/prisma/models/content.prisma
wdunn001 933ff37ccb
Some checks failed
Server CI / Lint (push) Failing after 6m33s
Server CI / Typecheck (push) Successful in 7m42s
community: M5 -- mods catalog and achievement definitions/display
Adds the M5 slice of the community layer: Mod/ModVersion/ModDependency/
ModInstallation/ModInstalledFile/AchievementDefinition (migration
m5_mods_achievements). Gods/Users are referenced as plain soft columns
(gameId/uploaderId/identityId), not Prisma relations, following the
concurrent-edit-avoidance pattern devices.prisma established -- content.prisma
and user.prisma only grow a comment each.

Mods: syncs from script-library/scripts/archive-mod.py's _index/catalog.json
(read-only bind mount, homelab-compose/drop-stack/docker-compose.yml) into
Mod/ModVersion/ModDependency, resolves dependency refs into real Mod rows
where archived, and exposes a topologically-ordered install-plan resolver
with cycle/conflict/unresolved-dependency detection
(GET /mods/:id/versions/:v/plan). The install manifest
(ModInstallation/ModInstalledFile) records created/overwrote/skipped per
file so an uninstall plan is exact, computed server-side from what was
recorded, applied by the caller. Downloads stream directly off the mount
(GET /mods/:id/versions/:v/download) since cdn.quasarke.net has no
file_server wired to /mnt/local24/game-mods yet -- documented as a known gap
in server/internal/community/README.md, deliberately not fixed by editing
the live Caddyfile. A manual add form covers the DESIGN.md open-question #4
fallback (no upload write path exists).

Achievements: imports gbe_fork's archived generate_emu_config output
(/mnt/local24/game-tools/goldberg/schemas, also read-only mounted) via
goldbergAdapter.ts, copying icons into Drop's own object store
(objectHandler.createFromSource, same mechanism as Steam cover art) so
nothing is hotlinked. Display joins AchievementDefinition against M2's
already-landed AchievementUnlock by (steamAppId, apiName), exactly the join
key M2 designed it around -- no stub needed, M2's table was already in the
tree. Verified against real fixtures: appid 245170 (Skullgirls) importing
45/45 definitions with 90 icons, and 274190 (Broforce) importing 17/17.

Pages: /community/mods, /community/mods/:slug, /community/mods/new,
/community/achievements, /community/games/:gameId (achievement grid +
per-title mods, completion %). Small additive nav links on /community's
index rather than touching the actively-changing shared game-detail page.
2026-08-03 01:16:25 -04:00

274 lines
7.2 KiB
Text

enum MetadataSource {
Manual
GiantBomb
Steam
PCGamingWiki
IGDB
Metacritic
OpenCritic
}
enum GameType {
Game
Emulator
Dependency
}
model Game {
id String @id @default(uuid())
metadataSource MetadataSource
metadataId String
created DateTime @default(now())
type GameType @default(Game)
// Any field prefixed with m is filled in from metadata
// Acts as a cache so we can search and filter it
mName String // Name of game
mShortDescription String // Short description
mDescription String // Supports markdown
mReleased DateTime // When the game was released
ratings GameRating[]
ageRatings GameAgeRating[]
featured Boolean @default(false)
mIconObjectId String // linked to objects in s3
mBannerObjectId String // linked to objects in s3
mCoverObjectId String
mImageCarouselObjectIds String[] @default([]) // linked to below array
mImageLibraryObjectIds String[] // linked to objects in s3
versions GameVersion[]
// 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], onDelete: Cascade, onUpdate: Cascade)
libraryPath String
collections CollectionEntry[]
saves SaveSlot[]
screenshots Screenshot[]
tags GameTag[]
playtime Playtime[]
developers Company[] @relation(name: "developers")
publishers Company[] @relation(name: "publishers")
unimportedGameVersions UnimportedGameVersion[]
// Note for M5 (mods/achievements) and other milestones: do NOT add a
// Prisma relation array here for a model owned by another milestone file.
// Prisma relations must be declared on both sides, which forces an edit to
// this shared file for every milestone in parallel -- exactly the
// concurrent-edit collision this fork's milestones were warned about (see
// devices.prisma's header). Mod/AchievementDefinition/etc reference Game.id
// as a plain, unenforced-by-FK column instead, resolved at the application
// layer -- same pattern devices.prisma already established for Device/
// PlaySession/AchievementUnlock.
@@unique([metadataSource, metadataId], name: "metadataKey")
@@unique([libraryId, libraryPath], name: "libraryKey")
@@index([mName(ops: raw("gist_trgm_ops(siglen=32)"))], type: Gist)
}
model GameTag {
id String @id @default(uuid())
name String @unique
games Game[]
@@index([name(ops: raw("gist_trgm_ops(siglen=32)"))], type: Gist)
}
enum AgeRatingOrganization {
ESRB
PEGI
CERO
USK
GRAC
ClassInd
ACB
}
model GameAgeRating {
id String @id @default(uuid())
organization AgeRatingOrganization
rating String // e.g. "E", "T", "M", "18", "CERO_B", comes from server enums
ratingCoverUrl String? // Badge image URL from IGDB, optional
game Game @relation(fields: [gameId], references: [id], onDelete: Cascade)
gameId String
@@unique([gameId, organization], name: "gameOrganizationKey")
}
model GameRating {
id String @id @default(uuid())
metadataSource MetadataSource
metadataId String
created DateTime @default(now())
mReviewCount Int
mReviewRating Float // 0 to 1
mReviewHref String?
game Game @relation(fields: [gameId], references: [id], onDelete: Cascade)
gameId String
@@unique([metadataSource, metadataId], name: "metadataKey")
}
model UnimportedGameVersion {
id String @id @default(uuid())
gameId String
game Game @relation(fields: [gameId], references: [id], onDelete: Cascade)
versionName String
manifest Json
fileList String[]
}
// A particular set of files that relate to the version
model GameVersion {
gameId String
game Game @relation(fields: [gameId], references: [id], onDelete: Cascade)
versionId String @id @default(uuid())
displayName String?
versionPath String?
created DateTime @default(now())
launches LaunchConfiguration[]
setups SetupConfiguration[]
onlySetup Boolean @default(false)
dropletManifest Json // Results from droplet
fileList String[] // List of all files, for delta updates
negativeFileList String[] // List of files to remove, for delta updates
versionIndex Int
delta Boolean @default(false)
requiredContent GameVersion[] @relation(name: "requiredContent")
requiringContent GameVersion[] @relation(name: "requiredContent")
}
model SetupConfiguration {
setupId String @id @default(uuid())
command String
platform Platform
versionId String
gameVersion GameVersion @relation(fields: [versionId], references: [versionId], onDelete: Cascade, onUpdate: Cascade)
}
model LaunchConfiguration {
launchId String @id @default(uuid())
name String
command String
platform Platform
// For emulation targets
emulatorId String?
emulator LaunchConfiguration? @relation(fields: [emulatorId], references: [launchId], name: "emulator")
emulatorSuggestions String[]
umuIdOverride String?
umuStoreOverride String?
versionId String
gameVersion GameVersion @relation(fields: [versionId], references: [versionId], onDelete: Cascade, onUpdate: Cascade)
emulations LaunchConfiguration[] @relation("emulator")
}
// A save slot for a game
model SaveSlot {
gameId String
game Game @relation(fields: [gameId], references: [id], onDelete: Cascade)
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
index Int
createdAt DateTime @default(now())
playtime Float @default(0) // hours
lastUsedClientId String?
lastUsedClient Client? @relation(fields: [lastUsedClientId], references: [id])
historyObjectIds String[] // list of objects
historyChecksums String[] // list of hashes
@@id([gameId, userId, index], name: "id")
}
model Screenshot {
id String @id @default(uuid())
gameId String
game Game @relation(fields: [gameId], references: [id], onDelete: Cascade)
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
objectId String
private Boolean // if other users can see
createdAt DateTime @default(now()) @db.Timestamptz(0)
@@index([gameId, userId])
@@index([userId])
}
model Playtime {
gameId String
game Game @relation(fields: [gameId], references: [id], onDelete: Cascade)
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
seconds Int // seconds user has spent playing the game
updatedAt DateTime @updatedAt @db.Timestamptz(6)
createdAt DateTime @default(now()) @db.Timestamptz(6)
@@id([gameId, userId])
@@index([userId])
}
model Company {
id String @id @default(uuid())
metadataSource MetadataSource
metadataId String
metadataOriginalQuery String
mName String
mShortDescription String
mDescription String
mLogoObjectId String
mBannerObjectId String
mWebsite String
developed Game[] @relation(name: "developers")
published Game[] @relation(name: "publishers")
@@unique([metadataSource, metadataId], name: "metadataKey")
}
model ObjectHash {
id String @id
hash String
}