191 lines
5.7 KiB
Plaintext
191 lines
5.7 KiB
Plaintext
// This is your Prisma schema file,
|
|
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
|
|
|
// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
|
|
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init
|
|
|
|
generator client {
|
|
provider = "prisma-client-js"
|
|
output = "../src/generated/prisma"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
model User {
|
|
steamId String @id
|
|
name String?
|
|
avatar String?
|
|
location String?
|
|
isAdmin Boolean @default(false)
|
|
teamId String? @unique
|
|
premierRank Int?
|
|
authCode String?
|
|
lastKnownShareCode String?
|
|
lastKnownShareCodeDate DateTime?
|
|
createdAt DateTime @default(now())
|
|
|
|
team Team? @relation("UserTeam", fields: [teamId], references: [id])
|
|
ledTeam Team? @relation("TeamLeader")
|
|
invitations Invitation[] @relation("UserInvitations")
|
|
notifications Notification[]
|
|
matchPlayers MatchPlayer[]
|
|
matchRequests CS2MatchRequest[] @relation("MatchRequests")
|
|
rankHistory PremierRankHistory[] @relation("UserRankHistory")
|
|
demoFiles DemoFile[]
|
|
}
|
|
|
|
model Team {
|
|
id String @id @default(cuid())
|
|
name String @unique
|
|
leaderId String? @unique
|
|
logo String?
|
|
createdAt DateTime @default(now())
|
|
activePlayers String[]
|
|
inactivePlayers String[]
|
|
leader User? @relation("TeamLeader", fields: [leaderId], references: [steamId])
|
|
members User[] @relation("UserTeam")
|
|
invitations Invitation[]
|
|
matchPlayers MatchPlayer[]
|
|
matchesAsTeamA Match[] @relation("TeamA")
|
|
matchesAsTeamB Match[] @relation("TeamB")
|
|
}
|
|
|
|
model Match {
|
|
matchId BigInt @id @default(autoincrement())
|
|
teamAId String?
|
|
teamBId String?
|
|
matchDate DateTime
|
|
matchType String @default("community")
|
|
map String?
|
|
title String
|
|
description String?
|
|
demoData Json?
|
|
demoFilePath String?
|
|
scoreA Int?
|
|
scoreB Int?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
teamA Team? @relation("TeamA", fields: [teamAId], references: [id])
|
|
teamB Team? @relation("TeamB", fields: [teamBId], references: [id])
|
|
demoFile DemoFile?
|
|
players MatchPlayer[]
|
|
rankUpdates PremierRankHistory[] @relation("MatchRankHistory")
|
|
}
|
|
|
|
model MatchPlayer {
|
|
id String @id @default(cuid())
|
|
matchId BigInt
|
|
steamId String
|
|
teamId String?
|
|
|
|
match Match @relation(fields: [matchId], references: [matchId])
|
|
user User @relation(fields: [steamId], references: [steamId])
|
|
team Team? @relation(fields: [teamId], references: [id])
|
|
stats MatchPlayerStats?
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
@@unique([matchId, steamId])
|
|
}
|
|
|
|
model MatchPlayerStats {
|
|
id String @id @default(cuid())
|
|
matchPlayerId String @unique
|
|
kills Int
|
|
assists Int
|
|
deaths Int
|
|
adr Float
|
|
headshotPct Float
|
|
|
|
flashAssists Int @default(0)
|
|
mvps Int @default(0)
|
|
mvpEliminations Int @default(0)
|
|
mvpDefuse Int @default(0)
|
|
mvpPlant Int @default(0)
|
|
knifeKills Int @default(0)
|
|
zeusKills Int @default(0)
|
|
wallbangKills Int @default(0)
|
|
smokeKills Int @default(0)
|
|
headshots Int @default(0)
|
|
noScopes Int @default(0)
|
|
blindKills Int @default(0)
|
|
|
|
rankOld Int?
|
|
rankNew Int?
|
|
winCount Int?
|
|
|
|
matchPlayer MatchPlayer @relation(fields: [matchPlayerId], references: [id])
|
|
}
|
|
|
|
model DemoFile {
|
|
id String @id @default(cuid())
|
|
matchId BigInt @unique
|
|
steamId String
|
|
fileName String @unique
|
|
filePath String
|
|
parsed Boolean @default(false)
|
|
createdAt DateTime @default(now())
|
|
|
|
match Match @relation(fields: [matchId], references: [matchId])
|
|
user User @relation(fields: [steamId], references: [steamId])
|
|
}
|
|
|
|
model Invitation {
|
|
id String @id @default(cuid())
|
|
userId String
|
|
teamId String
|
|
type String
|
|
createdAt DateTime @default(now())
|
|
|
|
user User @relation("UserInvitations", fields: [userId], references: [steamId])
|
|
team Team @relation(fields: [teamId], references: [id])
|
|
}
|
|
|
|
model Notification {
|
|
id String @id @default(uuid())
|
|
userId String
|
|
title String?
|
|
message String
|
|
read Boolean @default(false)
|
|
persistent Boolean @default(false)
|
|
actionType String?
|
|
actionData String?
|
|
createdAt DateTime @default(now())
|
|
|
|
user User @relation(fields: [userId], references: [steamId])
|
|
}
|
|
|
|
model CS2MatchRequest {
|
|
id String @id @default(cuid())
|
|
userId String
|
|
steamId String
|
|
matchId BigInt
|
|
reservationId BigInt
|
|
tvPort BigInt
|
|
processed Boolean @default(false)
|
|
createdAt DateTime @default(now())
|
|
|
|
user User @relation("MatchRequests", fields: [userId], references: [steamId])
|
|
|
|
@@unique([steamId, matchId])
|
|
}
|
|
|
|
model PremierRankHistory {
|
|
id String @id @default(cuid())
|
|
userId String
|
|
steamId String
|
|
matchId BigInt?
|
|
|
|
rankOld Int
|
|
rankNew Int
|
|
delta Int
|
|
winCount Int
|
|
createdAt DateTime @default(now())
|
|
|
|
user User @relation("UserRankHistory", fields: [userId], references: [steamId])
|
|
match Match? @relation("MatchRankHistory", fields: [matchId], references: [matchId])
|
|
} |