93 lines
2.5 KiB
Plaintext
93 lines
2.5 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 = "../generated/prisma"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
model Team {
|
|
id Int @id @default(autoincrement())
|
|
name String @unique
|
|
logo String? // Team logo URL or emoji
|
|
registeredAt DateTime @default(now())
|
|
players Player[]
|
|
matches1 Match[] @relation("Team1Matches")
|
|
matches2 Match[] @relation("Team2Matches")
|
|
resultsWon Result[] @relation("WinnerTeamResults")
|
|
}
|
|
|
|
model Player {
|
|
id Int @id @default(autoincrement())
|
|
name String
|
|
username String? @unique
|
|
registeredAt DateTime @default(now())
|
|
passwordHash String?
|
|
imageUrl String? // Optional profile image path
|
|
team Team? @relation(fields: [teamId], references: [id])
|
|
teamId Int?
|
|
}
|
|
|
|
model AdminUser {
|
|
id Int @id @default(autoincrement())
|
|
username String @unique
|
|
passwordHash String
|
|
}
|
|
|
|
model Tournament {
|
|
id Int @id @default(autoincrement())
|
|
name String
|
|
date DateTime
|
|
location String
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
stages TournamentStage[]
|
|
}
|
|
|
|
model TournamentStage {
|
|
id Int @id @default(autoincrement())
|
|
type StageType
|
|
startedAt DateTime?
|
|
endedAt DateTime?
|
|
matches Match[]
|
|
tier Int? // Added for tiered elimination
|
|
tournament Tournament @relation(fields: [tournamentId], references: [id])
|
|
tournamentId Int
|
|
}
|
|
|
|
enum StageType {
|
|
ROUND_ROBIN
|
|
SINGLE_ELIM
|
|
}
|
|
|
|
model Match {
|
|
id Int @id @default(autoincrement())
|
|
stage TournamentStage @relation(fields: [stageId], references: [id])
|
|
stageId Int
|
|
team1 Team @relation("Team1Matches", fields: [team1Id], references: [id])
|
|
team1Id Int
|
|
team2 Team @relation("Team2Matches", fields: [team2Id], references: [id])
|
|
team2Id Int
|
|
scheduledAt DateTime
|
|
result Result?
|
|
pool Int
|
|
}
|
|
|
|
model Result {
|
|
id Int @id @default(autoincrement())
|
|
match Match @relation(fields: [matchId], references: [id])
|
|
matchId Int @unique
|
|
team1Score Int
|
|
team2Score Int
|
|
winner Team @relation("WinnerTeamResults", fields: [winnerId], references: [id])
|
|
winnerId Int
|
|
}
|