224 lines
6.0 KiB
Plaintext
224 lines
6.0 KiB
Plaintext
generator client {
|
|
provider = "prisma-client-js"
|
|
output = "../src/generated/prisma"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
//
|
|
// ──────────────────────────────────────────────
|
|
// 🧑 Benutzer, Teams & Verwaltung
|
|
// ──────────────────────────────────────────────
|
|
//
|
|
|
|
model User {
|
|
steamId String @id
|
|
name String?
|
|
avatar String?
|
|
location String?
|
|
isAdmin Boolean @default(false)
|
|
|
|
teamId String? @unique
|
|
team Team? @relation("UserTeam", fields: [teamId], references: [id])
|
|
ledTeam Team? @relation("TeamLeader")
|
|
|
|
premierRank Int?
|
|
authCode String?
|
|
lastKnownShareCode String?
|
|
lastKnownShareCodeDate DateTime?
|
|
createdAt DateTime @default(now())
|
|
|
|
invites TeamInvite[] @relation("UserInvitations")
|
|
notifications Notification[]
|
|
matchPlayers MatchPlayer[]
|
|
serverRequests ServerRequest[] @relation("MatchRequests")
|
|
rankHistory RankHistory[] @relation("UserRankHistory")
|
|
demoFiles DemoFile[]
|
|
}
|
|
|
|
model Team {
|
|
id String @id @default(uuid())
|
|
name String @unique
|
|
logo String?
|
|
leaderId String? @unique
|
|
createdAt DateTime @default(now())
|
|
|
|
activePlayers String[]
|
|
inactivePlayers String[]
|
|
|
|
leader User? @relation("TeamLeader", fields: [leaderId], references: [steamId])
|
|
members User[] @relation("UserTeam")
|
|
invites TeamInvite[]
|
|
matchesAsTeamA Match[] @relation("Match_TeamA")
|
|
matchesAsTeamB Match[] @relation("Match_TeamB")
|
|
matchPlayers MatchPlayer[]
|
|
}
|
|
|
|
model TeamInvite {
|
|
id String @id @default(uuid())
|
|
steamId String
|
|
teamId String
|
|
type String
|
|
createdAt DateTime @default(now())
|
|
|
|
user User @relation("UserInvitations", fields: [steamId], references: [steamId])
|
|
team Team @relation(fields: [teamId], references: [id])
|
|
}
|
|
|
|
model Notification {
|
|
id String @id @default(uuid())
|
|
steamId 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: [steamId], references: [steamId])
|
|
}
|
|
|
|
//
|
|
// ──────────────────────────────────────────────
|
|
// 🎮 Matches & Spieler
|
|
// ──────────────────────────────────────────────
|
|
//
|
|
|
|
model Match {
|
|
id String @id @default(uuid())
|
|
title String
|
|
matchType String @default("community")
|
|
map String?
|
|
description String?
|
|
scoreA Int?
|
|
scoreB Int?
|
|
|
|
teamAId String?
|
|
teamBId String?
|
|
teamA Team? @relation("Match_TeamA", fields: [teamAId], references: [id])
|
|
teamB Team? @relation("Match_TeamB", fields: [teamBId], references: [id])
|
|
|
|
filePath String?
|
|
demoFile DemoFile?
|
|
demoDate DateTime?
|
|
demoData Json?
|
|
|
|
players MatchPlayer[]
|
|
rankUpdates RankHistory[] @relation("MatchRankHistory")
|
|
|
|
roundCount Int?
|
|
roundHistory Json?
|
|
winnerTeam String?
|
|
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
}
|
|
|
|
model MatchPlayer {
|
|
id String @id @default(uuid())
|
|
steamId String
|
|
matchId String
|
|
teamId String?
|
|
team Team? @relation(fields: [teamId], references: [id])
|
|
|
|
match Match @relation(fields: [matchId], references: [id])
|
|
user User @relation(fields: [steamId], references: [steamId])
|
|
|
|
stats PlayerStats?
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
@@unique([matchId, steamId])
|
|
}
|
|
|
|
model PlayerStats {
|
|
id String @id @default(uuid())
|
|
matchId String
|
|
steamId String
|
|
|
|
kills Int
|
|
assists Int
|
|
deaths Int
|
|
headshotPct Float
|
|
|
|
totalDamage Float @default(0)
|
|
utilityDamage Int @default(0)
|
|
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: [matchId, steamId], references: [matchId, steamId])
|
|
|
|
@@unique([matchId, steamId])
|
|
}
|
|
|
|
|
|
model RankHistory {
|
|
id String @id @default(uuid())
|
|
steamId String
|
|
matchId String?
|
|
|
|
rankOld Int
|
|
rankNew Int
|
|
delta Int
|
|
winCount Int
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
user User @relation("UserRankHistory", fields: [steamId], references: [steamId])
|
|
match Match? @relation("MatchRankHistory", fields: [matchId], references: [id])
|
|
}
|
|
|
|
//
|
|
// ──────────────────────────────────────────────
|
|
// 📦 Demo-Dateien & CS2 Requests
|
|
// ──────────────────────────────────────────────
|
|
//
|
|
|
|
model DemoFile {
|
|
id String @id @default(uuid())
|
|
matchId String @unique
|
|
steamId String
|
|
fileName String @unique
|
|
filePath String
|
|
parsed Boolean @default(false)
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
match Match @relation(fields: [matchId], references: [id])
|
|
user User @relation(fields: [steamId], references: [steamId])
|
|
}
|
|
|
|
model ServerRequest {
|
|
id String @id @default(uuid())
|
|
steamId String
|
|
matchId String
|
|
reservationId BigInt
|
|
tvPort BigInt
|
|
processed Boolean @default(false)
|
|
failed Boolean @default(false)
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
user User @relation("MatchRequests", fields: [steamId], references: [steamId])
|
|
|
|
@@unique([steamId, matchId])
|
|
}
|