mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-13 16:22:39 +10:00
refactor: split prisma schemas
This commit is contained in:
@ -6,174 +6,10 @@
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
previewFeatures = ["prismaSchemaFolder"]
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
model ApplicationSettings {
|
||||
timestamp DateTime @id @default(now())
|
||||
|
||||
enabledAuthencationMechanisms AuthMec[]
|
||||
}
|
||||
|
||||
model User {
|
||||
id String @id @default(uuid())
|
||||
username String @unique
|
||||
admin Boolean @default(false)
|
||||
|
||||
email String
|
||||
displayName String
|
||||
profilePicture String // Object
|
||||
|
||||
authMecs LinkedAuthMec[]
|
||||
clients Client[]
|
||||
}
|
||||
|
||||
enum AuthMec {
|
||||
Simple
|
||||
}
|
||||
|
||||
model LinkedAuthMec {
|
||||
userId String
|
||||
mec AuthMec
|
||||
|
||||
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 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)
|
||||
}
|
||||
|
||||
enum Platform {
|
||||
Windows @map("windows")
|
||||
Linux @map("linux")
|
||||
}
|
||||
|
||||
// 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?
|
||||
}
|
||||
|
||||
model ClientPeerAPIConfiguration {
|
||||
id String @id @default(uuid())
|
||||
|
||||
clientId String @unique
|
||||
client Client @relation(fields: [clientId], references: [id])
|
||||
|
||||
endpoints String[]
|
||||
}
|
||||
|
||||
enum MetadataSource {
|
||||
Custom
|
||||
GiantBomb
|
||||
}
|
||||
|
||||
model Game {
|
||||
id String @id @default(uuid())
|
||||
|
||||
metadataSource MetadataSource
|
||||
metadataId String
|
||||
|
||||
// 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[]
|
||||
|
||||
mReviewCount Int
|
||||
mReviewRating Float
|
||||
|
||||
mIconId String // linked to objects in s3
|
||||
mBannerId String // linked to objects in s3
|
||||
mCoverId String
|
||||
mImageLibrary String[] // linked to objects in s3
|
||||
|
||||
versions GameVersion[]
|
||||
libraryBasePath String @unique // Base dir for all the game versions
|
||||
|
||||
@@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])
|
||||
versionName String // Sub directory for the game files
|
||||
|
||||
platform Platform
|
||||
launchCommand String // Command to run to start. Platform-specific. Windows games on Linux will wrap this command in Proton/Wine
|
||||
setupCommand String // Command to setup game (dependencies and such)
|
||||
dropletManifest Json // Results from droplet
|
||||
|
||||
versionIndex Int
|
||||
delta Boolean @default(false)
|
||||
|
||||
@@id([gameId, versionName])
|
||||
}
|
||||
|
||||
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")
|
||||
}
|
||||
|
||||
10
prisma/schema/app.prisma
Normal file
10
prisma/schema/app.prisma
Normal file
@ -0,0 +1,10 @@
|
||||
model ApplicationSettings {
|
||||
timestamp DateTime @id @default(now())
|
||||
|
||||
enabledAuthencationMechanisms AuthMec[]
|
||||
}
|
||||
|
||||
enum Platform {
|
||||
Windows @map("windows")
|
||||
Linux @map("linux")
|
||||
}
|
||||
23
prisma/schema/auth.prisma
Normal file
23
prisma/schema/auth.prisma
Normal file
@ -0,0 +1,23 @@
|
||||
enum AuthMec {
|
||||
Simple
|
||||
}
|
||||
|
||||
model LinkedAuthMec {
|
||||
userId String
|
||||
mec AuthMec
|
||||
|
||||
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
|
||||
}
|
||||
28
prisma/schema/client.prisma
Normal file
28
prisma/schema/client.prisma
Normal file
@ -0,0 +1,28 @@
|
||||
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)
|
||||
}
|
||||
|
||||
// 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?
|
||||
}
|
||||
|
||||
model ClientPeerAPIConfiguration {
|
||||
id String @id @default(uuid())
|
||||
|
||||
clientId String @unique
|
||||
client Client @relation(fields: [clientId], references: [id])
|
||||
|
||||
endpoints String[]
|
||||
}
|
||||
87
prisma/schema/content.prisma
Normal file
87
prisma/schema/content.prisma
Normal file
@ -0,0 +1,87 @@
|
||||
enum MetadataSource {
|
||||
Custom
|
||||
GiantBomb
|
||||
}
|
||||
|
||||
model Game {
|
||||
id String @id @default(uuid())
|
||||
|
||||
metadataSource MetadataSource
|
||||
metadataId String
|
||||
|
||||
// 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[]
|
||||
|
||||
mReviewCount Int
|
||||
mReviewRating Float
|
||||
|
||||
mIconId String // linked to objects in s3
|
||||
mBannerId String // linked to objects in s3
|
||||
mCoverId String
|
||||
mImageLibrary String[] // linked to objects in s3
|
||||
|
||||
versions GameVersion[]
|
||||
libraryBasePath String @unique // Base dir for all the game versions
|
||||
|
||||
@@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])
|
||||
versionName String // Sub directory for the game files
|
||||
|
||||
platform Platform
|
||||
launchCommand String // Command to run to start. Platform-specific. Windows games on Linux will wrap this command in Proton/Wine
|
||||
setupCommand String // Command to setup game (dependencies and such)
|
||||
dropletManifest Json // Results from droplet
|
||||
|
||||
versionIndex Int
|
||||
delta Boolean @default(false)
|
||||
|
||||
@@id([gameId, versionName])
|
||||
}
|
||||
|
||||
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")
|
||||
}
|
||||
12
prisma/schema/user.prisma
Normal file
12
prisma/schema/user.prisma
Normal file
@ -0,0 +1,12 @@
|
||||
model User {
|
||||
id String @id @default(uuid())
|
||||
username String @unique
|
||||
admin Boolean @default(false)
|
||||
|
||||
email String
|
||||
displayName String
|
||||
profilePicture String // Object
|
||||
|
||||
authMecs LinkedAuthMec[]
|
||||
clients Client[]
|
||||
}
|
||||
Reference in New Issue
Block a user