fix: refactor prisma multifolder into docs example

This commit is contained in:
DecDuck
2025-05-08 16:25:01 +10:00
parent 867772d7ec
commit b90683e973
8 changed files with 1 additions and 1 deletions
+15
View File
@@ -0,0 +1,15 @@
model ApplicationSettings {
timestamp DateTime @id @default(now())
metadataProviders String[]
saveSlotCountLimit Int @default(5)
saveSlotSizeLimit Float @default(10) // MB
saveSlotHistoryLimit Int @default(3)
}
enum Platform {
Windows @map("windows")
Linux @map("linux")
macOS @map("macos")
}
+68
View File
@@ -0,0 +1,68 @@
enum AuthMec {
Simple
OpenID
}
model LinkedAuthMec {
userId String
mec AuthMec
enabled Boolean @default(true)
version Int @default(1)
credentials Json
user User @relation(fields: [userId], references: [id])
@@id([userId, mec])
}
model Invitation {
id String @id @default(uuid())
isAdmin Boolean @default(false)
username String?
email String?
expires DateTime
}
enum APITokenMode {
User
System
Client
}
model APIToken {
id String @id @default(uuid())
token String @unique @default(uuid())
mode APITokenMode
name String
userId String?
user User? @relation(fields: [userId], references: [id])
clientId String?
client Client? @relation(fields: [clientId], references: [id], onDelete: Cascade)
acls String[]
@@index([token])
}
model Certificate {
id String @id @default(uuid())
privateKey String
certificate String
blacklisted Boolean @default(false)
}
model Session {
token String @id
expiresAt DateTime
userId String
user User? @relation(fields: [userId], references: [id])
data Json // misc extra data
}
+32
View File
@@ -0,0 +1,32 @@
enum ClientCapabilities {
PeerAPI @map("peerAPI") // other clients can use the HTTP API to P2P with this client
UserStatus @map("userStatus") // this client can report this user's status (playing, online, etc etc)
CloudSaves @map("cloudSaves") // ability to save to save slots
}
// References a device
model Client {
id String @id @default(uuid())
userId String
user User @relation(fields: [userId], references: [id])
capabilities ClientCapabilities[]
name String
platform Platform
lastConnected DateTime
peerAPI ClientPeerAPIConfiguration?
lastAccessedSaves SaveSlot[]
tokens APIToken[]
}
model ClientPeerAPIConfiguration {
id String @id @default(uuid())
clientId String @unique
client Client @relation(fields: [clientId], references: [id])
endpoints String[]
}
+20
View File
@@ -0,0 +1,20 @@
model Collection {
id String @id @default(uuid())
name String
isDefault Boolean @default(false)
userId String
user User @relation(fields: [userId], references: [id])
entries CollectionEntry[]
}
model CollectionEntry {
collectionId String
collection Collection @relation(fields: [collectionId], references: [id], onDelete: Cascade)
gameId String
game Game @relation(fields: [gameId], references: [id], onDelete: Cascade)
@@id([collectionId, gameId])
}
+129
View File
@@ -0,0 +1,129 @@
enum MetadataSource {
Manual
GiantBomb
PCGamingWiki
IGDB
}
model Game {
id String @id @default(uuid())
metadataSource MetadataSource
metadataId String
created DateTime @default(now())
// 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
mDevelopers Developer[]
mPublishers Publisher[]
mReleased DateTime // When the game was released
mReviewCount Int
mReviewRating Float // 0 to 1
mIconId String // linked to objects in s3
mBannerId String // linked to objects in s3
mCoverId String
mImageCarousel String[] // linked to below array
mImageLibrary String[] // linked to objects in s3
versions GameVersion[]
libraryBasePath String @unique // Base dir for all the game versions
collections CollectionEntry[]
saves SaveSlot[]
@@unique([metadataSource, metadataId], name: "metadataKey")
}
// A particular set of files that relate to the version
model GameVersion {
gameId String
game Game @relation(fields: [gameId], references: [id], onDelete: Cascade)
versionName String // Sub directory for the game files
created DateTime @default(now())
platform Platform
launchCommand String @default("") // Command to run to start. Platform-specific. Windows games on Linux will wrap this command in Proton/Wine
launchArgs String[]
setupCommand String @default("") // Command to setup game (dependencies and such)
setupArgs String[]
onlySetup Boolean @default(false)
umuIdOverride String?
dropletManifest Json // Results from droplet
versionIndex Int
delta Boolean @default(false)
@@id([gameId, versionName])
}
// 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])
history String[] // list of objects
historyChecksums String[] // list of hashes
@@id([gameId, userId, index], name: "id")
}
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
}
+21
View File
@@ -0,0 +1,21 @@
model Tag {
id String @id @default(uuid())
name String @unique
articles Article[]
}
model Article {
id String @id @default(uuid())
title String
description String
content String @db.Text
tags Tag[]
image String? // Object ID
publishedAt DateTime @default(now())
author User? @relation(fields: [authorId], references: [id]) // Optional, if no user, it's a system post
authorId String?
}
+37
View File
@@ -0,0 +1,37 @@
model User {
id String @id @default(uuid())
username String @unique
admin Boolean @default(false)
enabled Boolean @default(true)
email String
displayName String
profilePicture String // Object
authMecs LinkedAuthMec[]
clients Client[]
notifications Notification[]
collections Collection[]
articles Article[]
tokens APIToken[]
sessions Session[]
saves SaveSlot[]
}
model Notification {
id String @id @default(uuid())
nonce String? @unique
userId String
user User @relation(fields: [userId], references: [id])
created DateTime @default(now())
title String
description String
actions String[]
read Boolean @default(false)
}