refactor(schema): update Match model to use player fields instead of team fields
This commit is contained in:
+50
-65
@@ -7,32 +7,34 @@ datasource db {
|
||||
}
|
||||
|
||||
model Player {
|
||||
id Int @id @default(autoincrement())
|
||||
name String
|
||||
rating Int @default(0)
|
||||
currentElo Int @default(1000)
|
||||
gamesPlayed Int @default(0)
|
||||
wins Int @default(0)
|
||||
losses Int @default(0)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
normalizedName String @unique
|
||||
eloSnapshots EloSnapshot[]
|
||||
eventParticipants EventParticipant[]
|
||||
matchesAsP1 Match[] @relation("MatchPlayer1")
|
||||
matchesAsP2 Match[] @relation("MatchPlayer2")
|
||||
matchesAsP3 Match[] @relation("MatchPlayer3")
|
||||
matchesAsP4 Match[] @relation("MatchPlayer4")
|
||||
partnershipGames PartnershipGame[] @relation("PartnershipPlayer1")
|
||||
partnershipGames2 PartnershipGame[] @relation("PartnershipPlayer2")
|
||||
partnershipStats PartnershipStat[] @relation("StatPlayer1")
|
||||
partnershipStats2 PartnershipStat[] @relation("StatPlayer2")
|
||||
teamsAsPlayer1 Team[] @relation("TeamPlayer1")
|
||||
teamsAsPlayer2 Team[] @relation("TeamPlayer2")
|
||||
user User?
|
||||
eloRating EloRating?
|
||||
glicko2Rating Glicko2Rating?
|
||||
openSkillRating OpenSkillRating?
|
||||
id Int @id @default(autoincrement())
|
||||
name String
|
||||
rating Int @default(0)
|
||||
currentElo Int @default(1000)
|
||||
gamesPlayed Int @default(0)
|
||||
wins Int @default(0)
|
||||
losses Int @default(0)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
normalizedName String @unique
|
||||
eloSnapshots EloSnapshot[]
|
||||
eventParticipants EventParticipant[]
|
||||
matchesAsP1 Match[] @relation("MatchPlayer1")
|
||||
matchesAsP2 Match[] @relation("MatchPlayer2")
|
||||
matchesAsP3 Match[] @relation("MatchPlayer3")
|
||||
matchesAsP4 Match[] @relation("MatchPlayer4")
|
||||
partnershipGames PartnershipGame[] @relation("PartnershipPlayer1")
|
||||
partnershipGames2 PartnershipGame[] @relation("PartnershipPlayer2")
|
||||
partnershipStats PartnershipStat[] @relation("StatPlayer1")
|
||||
partnershipStats2 PartnershipStat[] @relation("StatPlayer2")
|
||||
user User?
|
||||
eloRating EloRating?
|
||||
glicko2Rating Glicko2Rating?
|
||||
openSkillRating OpenSkillRating?
|
||||
bracketMatchupsAsP1P1 BracketMatchup[] @relation("BracketMatchupPlayer1P1")
|
||||
bracketMatchupsAsP1P2 BracketMatchup[] @relation("BracketMatchupPlayer1P2")
|
||||
bracketMatchupsAsP2P1 BracketMatchup[] @relation("BracketMatchupPlayer2P1")
|
||||
bracketMatchupsAsP2P2 BracketMatchup[] @relation("BracketMatchupPlayer2P2")
|
||||
|
||||
@@map("players")
|
||||
}
|
||||
@@ -76,16 +78,15 @@ model Event {
|
||||
participants EventParticipant[]
|
||||
owner User? @relation("TournamentOwner", fields: [ownerId], references: [id])
|
||||
matches Match[]
|
||||
teams Team[]
|
||||
rounds TournamentRound[]
|
||||
|
||||
// Team configuration fields
|
||||
teamDurability String @default("permanent") // permanent, variable, per_round
|
||||
partnerRotation String @default("none") // none, minimize_repeat, maximize_even, elo_based
|
||||
allowByes Boolean @default(true)
|
||||
teamConfiguration Json? // Additional configuration options
|
||||
maxRosterChanges Int? // Maximum roster changes per player
|
||||
requireAdminVerify Boolean @default(false) // For match score verification
|
||||
teamDurability String @default("permanent") // permanent, variable, per_round
|
||||
partnerRotation String @default("none") // none, minimize_repeat, maximize_even, elo_based
|
||||
allowByes Boolean @default(true)
|
||||
teamConfiguration Json? // Additional configuration options
|
||||
maxRosterChanges Int? // Maximum roster changes per player
|
||||
requireAdminVerify Boolean @default(false) // For match score verification
|
||||
|
||||
@@map("events")
|
||||
}
|
||||
@@ -94,7 +95,6 @@ model EventParticipant {
|
||||
id Int @id @default(autoincrement())
|
||||
eventId Int
|
||||
playerId Int
|
||||
teamId Int?
|
||||
seed Int?
|
||||
status String @default("registered")
|
||||
registrationDate DateTime?
|
||||
@@ -102,30 +102,11 @@ model EventParticipant {
|
||||
updatedAt DateTime @updatedAt
|
||||
event Event @relation(fields: [eventId], references: [id])
|
||||
player Player @relation(fields: [playerId], references: [id])
|
||||
team Team? @relation(fields: [teamId], references: [id])
|
||||
|
||||
@@unique([eventId, playerId])
|
||||
@@map("event_participants")
|
||||
}
|
||||
|
||||
model Team {
|
||||
id Int @id @default(autoincrement())
|
||||
eventId Int
|
||||
teamName String?
|
||||
player1Id Int
|
||||
player2Id Int
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
bracketMatchups1 BracketMatchup[] @relation("BracketTeam1")
|
||||
bracketMatchups2 BracketMatchup[] @relation("BracketTeam2")
|
||||
eventParticipants EventParticipant[]
|
||||
event Event @relation(fields: [eventId], references: [id])
|
||||
player1 Player @relation("TeamPlayer1", fields: [player1Id], references: [id])
|
||||
player2 Player @relation("TeamPlayer2", fields: [player2Id], references: [id])
|
||||
|
||||
@@map("teams")
|
||||
}
|
||||
|
||||
model TournamentRound {
|
||||
id Int @id @default(autoincrement())
|
||||
eventId Int
|
||||
@@ -146,8 +127,10 @@ model BracketMatchup {
|
||||
id Int @id @default(autoincrement())
|
||||
roundId Int
|
||||
eventId Int
|
||||
team1Id Int?
|
||||
team2Id Int?
|
||||
player1P1Id Int?
|
||||
player1P2Id Int?
|
||||
player2P1Id Int?
|
||||
player2P2Id Int?
|
||||
matchId Int?
|
||||
tableNumber Int?
|
||||
bracketPosition Int?
|
||||
@@ -159,8 +142,10 @@ model BracketMatchup {
|
||||
event Event @relation(fields: [eventId], references: [id])
|
||||
match Match? @relation(fields: [matchId], references: [id], onDelete: Cascade)
|
||||
round TournamentRound @relation(fields: [roundId], references: [id])
|
||||
team1 Team? @relation("BracketTeam1", fields: [team1Id], references: [id])
|
||||
team2 Team? @relation("BracketTeam2", fields: [team2Id], references: [id])
|
||||
player1P1 Player? @relation("BracketMatchupPlayer1P1", fields: [player1P1Id], references: [id])
|
||||
player1P2 Player? @relation("BracketMatchupPlayer1P2", fields: [player1P2Id], references: [id])
|
||||
player2P1 Player? @relation("BracketMatchupPlayer2P1", fields: [player2P1Id], references: [id])
|
||||
player2P2 Player? @relation("BracketMatchupPlayer2P2", fields: [player2P2Id], references: [id])
|
||||
|
||||
@@map("bracket_matchups")
|
||||
}
|
||||
@@ -169,10 +154,10 @@ model Match {
|
||||
id Int @id @default(autoincrement())
|
||||
eventId Int?
|
||||
playedAt DateTime?
|
||||
team1P1Id Int
|
||||
team1P2Id Int
|
||||
team2P1Id Int
|
||||
team2P2Id Int
|
||||
player1P1Id Int?
|
||||
player1P2Id Int?
|
||||
player2P1Id Int?
|
||||
player2P2Id Int?
|
||||
team1Score Int
|
||||
team2Score Int
|
||||
status String @default("completed")
|
||||
@@ -184,10 +169,10 @@ model Match {
|
||||
eloSnapshots EloSnapshot[]
|
||||
createdBy User? @relation("MatchCreator", fields: [createdById], references: [id])
|
||||
event Event? @relation(fields: [eventId], references: [id], onDelete: Cascade)
|
||||
team1P1 Player @relation("MatchPlayer1", fields: [team1P1Id], references: [id])
|
||||
team1P2 Player @relation("MatchPlayer2", fields: [team1P2Id], references: [id])
|
||||
team2P1 Player @relation("MatchPlayer3", fields: [team2P1Id], references: [id])
|
||||
team2P2 Player @relation("MatchPlayer4", fields: [team2P2Id], references: [id])
|
||||
player1P1 Player? @relation("MatchPlayer1", fields: [player1P1Id], references: [id])
|
||||
player1P2 Player? @relation("MatchPlayer2", fields: [player1P2Id], references: [id])
|
||||
player2P1 Player? @relation("MatchPlayer3", fields: [player2P1Id], references: [id])
|
||||
player2P2 Player? @relation("MatchPlayer4", fields: [player2P2Id], references: [id])
|
||||
partnershipGames PartnershipGame[]
|
||||
|
||||
@@map("matches")
|
||||
|
||||
Reference in New Issue
Block a user