From 26d6bf8aa5a03ca342f1ee855d470876520c413f Mon Sep 17 00:00:00 2001 From: David Gwilliam Date: Tue, 31 Mar 2026 03:39:30 -0700 Subject: [PATCH] feat: add OpenSkill and Glicko2 rating models to schema --- prisma/schema.prisma | 55 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 8dbf70c..e223385 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -30,6 +30,9 @@ model Player { teamsAsPlayer1 Team[] @relation("TeamPlayer1") teamsAsPlayer2 Team[] @relation("TeamPlayer2") user User? + eloRating EloRating? + glicko2Rating Glicko2Rating? + openSkillRating OpenSkillRating? @@map("players") } @@ -276,3 +279,55 @@ model Verification { @@index([identifier]) @@map("verification") } + +model EloRating { + id Int @id @default(autoincrement()) + playerId Int @unique + rating Int @default(1000) + volatility Float @default(0) // Optional: for advanced Elo variants + gamesPlayed Int @default(0) + wins Int @default(0) + losses Int @default(0) + draws Int @default(0) + lastUpdated DateTime @default(now()) + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + player Player @relation(fields: [playerId], references: [id], onDelete: Cascade) + + @@map("elo_ratings") +} + +model Glicko2Rating { + id Int @id @default(autoincrement()) + playerId Int @unique + rating Float @default(1500.0) // mu + deviation Float @default(350.0) // phi + volatility Float @default(0.05) // sigma + gamesPlayed Int @default(0) + wins Int @default(0) + losses Int @default(0) + draws Int @default(0) + lastUpdated DateTime @default(now()) + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + player Player @relation(fields: [playerId], references: [id], onDelete: Cascade) + + @@map("glicko2_ratings") +} + +model OpenSkillRating { + id Int @id @default(autoincrement()) + playerId Int @unique + rating Float @default(25.0) // mu + deviation Float @default(8.33) // sigma (std dev) + gamesPlayed Int @default(0) + wins Int @default(0) + losses Int @default(0) + draws Int @default(0) + lastUpdated DateTime @default(now()) + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + player Player @relation(fields: [playerId], references: [id], onDelete: Cascade) + + @@map("open_skill_ratings") +}