generator client { provider = "prisma-client-js" } datasource db { provider = "postgresql" url = env("DATABASE_URL") } model User { id String @id @default(cuid()) email String @unique password String name String role Role @default(PLAYER) predictions Prediction[] createdAt DateTime @default(now()) updatedAt DateTime @updatedAt } enum Role { ADMIN PLAYER } model Team { id String @id @default(cuid()) name String shortName String @unique isoCode String @unique group String groupOrder Int confederation String homeMatches Match[] @relation("HomeTeam") awayMatches Match[] @relation("AwayTeam") @@index([group]) } model Match { id String @id @default(cuid()) matchNumber Int @unique phase Phase group String? matchday Int? homeTeam Team? @relation("HomeTeam", fields: [homeTeamId], references: [id]) homeTeamId String? awayTeam Team? @relation("AwayTeam", fields: [awayTeamId], references: [id]) awayTeamId String? homeLabel String? awayLabel String? scheduledAt DateTime venue String? homeScore Int? awayScore Int? status MatchStatus @default(SCHEDULED) predictions Prediction[] createdAt DateTime @default(now()) updatedAt DateTime @updatedAt @@index([phase]) @@index([group]) @@index([status]) @@index([scheduledAt]) } enum Phase { GROUP_STAGE ROUND_OF_32 ROUND_OF_16 QUARTER_FINALS SEMI_FINALS THIRD_PLACE FINAL } enum MatchStatus { SCHEDULED LIVE FINISHED } model Prediction { id String @id @default(cuid()) user User @relation(fields: [userId], references: [id]) userId String match Match @relation(fields: [matchId], references: [id]) matchId String result PredictionResult points Int? createdAt DateTime @default(now()) updatedAt DateTime @updatedAt @@unique([userId, matchId]) @@index([userId]) @@index([matchId]) } enum PredictionResult { HOME DRAW AWAY }