2026-01-03 14:07:04 +00:00
|
|
|
|
// This is your Prisma schema file,
|
|
|
|
|
|
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
|
|
|
|
|
|
|
|
|
|
|
generator client {
|
|
|
|
|
|
provider = "prisma-client-js"
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
datasource db {
|
|
|
|
|
|
provider = "postgresql"
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
model User {
|
2026-01-06 20:12:36 +00:00
|
|
|
|
id String @id @default(uuid())
|
|
|
|
|
|
email String? @unique
|
|
|
|
|
|
name String?
|
|
|
|
|
|
password String? // For optional email/password admin auth
|
|
|
|
|
|
role UserRole @default(USER)
|
|
|
|
|
|
telegramId String? @unique
|
|
|
|
|
|
createdAt DateTime @default(now())
|
2026-01-03 14:07:04 +00:00
|
|
|
|
|
|
|
|
|
|
// Связи
|
|
|
|
|
|
hostedRooms Room[] @relation("HostedRooms")
|
|
|
|
|
|
participants Participant[]
|
|
|
|
|
|
questionPacks QuestionPack[]
|
2026-01-09 18:05:31 +00:00
|
|
|
|
themes Theme[]
|
2026-01-03 14:07:04 +00:00
|
|
|
|
|
|
|
|
|
|
// Статистика
|
|
|
|
|
|
gamesPlayed Int @default(0)
|
|
|
|
|
|
gamesWon Int @default(0)
|
|
|
|
|
|
totalPoints Int @default(0)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
model Room {
|
|
|
|
|
|
id String @id @default(uuid())
|
|
|
|
|
|
code String @unique // 6-символьный код
|
|
|
|
|
|
status RoomStatus @default(WAITING)
|
|
|
|
|
|
hostId String
|
|
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
|
|
expiresAt DateTime
|
|
|
|
|
|
|
|
|
|
|
|
// Настройки
|
|
|
|
|
|
maxPlayers Int @default(10)
|
|
|
|
|
|
allowSpectators Boolean @default(true)
|
|
|
|
|
|
timerEnabled Boolean @default(false)
|
|
|
|
|
|
timerDuration Int @default(30)
|
2026-01-06 20:12:36 +00:00
|
|
|
|
questionPackId String?
|
2026-01-03 14:07:04 +00:00
|
|
|
|
autoAdvance Boolean @default(false)
|
2026-01-08 13:18:07 +00:00
|
|
|
|
voiceMode Boolean @default(false) // Голосовой режим
|
2026-01-03 14:07:04 +00:00
|
|
|
|
|
|
|
|
|
|
// Состояние игры
|
|
|
|
|
|
currentQuestionIndex Int @default(0)
|
2026-01-08 21:44:38 +00:00
|
|
|
|
currentQuestionId String? // UUID текущего вопроса
|
|
|
|
|
|
revealedAnswers Json @default("{}") // {"questionUuid": ["answerUuid1", "answerUuid2"]}
|
2026-01-03 14:07:04 +00:00
|
|
|
|
currentPlayerId String?
|
|
|
|
|
|
isGameOver Boolean @default(false)
|
|
|
|
|
|
|
|
|
|
|
|
// Метрики
|
|
|
|
|
|
totalQuestions Int @default(0)
|
|
|
|
|
|
answeredQuestions Int @default(0)
|
|
|
|
|
|
startedAt DateTime?
|
|
|
|
|
|
finishedAt DateTime?
|
|
|
|
|
|
|
|
|
|
|
|
// Связи
|
|
|
|
|
|
host User @relation("HostedRooms", fields: [hostId], references: [id])
|
|
|
|
|
|
participants Participant[]
|
2026-01-06 20:12:36 +00:00
|
|
|
|
questionPack QuestionPack? @relation(fields: [questionPackId], references: [id])
|
2026-01-08 17:56:00 +00:00
|
|
|
|
roomPack RoomPack?
|
2026-01-03 14:07:04 +00:00
|
|
|
|
gameHistory GameHistory?
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
enum RoomStatus {
|
|
|
|
|
|
WAITING
|
|
|
|
|
|
PLAYING
|
|
|
|
|
|
FINISHED
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
model Participant {
|
|
|
|
|
|
id String @id @default(uuid())
|
|
|
|
|
|
userId String
|
|
|
|
|
|
roomId String
|
|
|
|
|
|
name String
|
|
|
|
|
|
role ParticipantRole
|
|
|
|
|
|
score Int @default(0)
|
|
|
|
|
|
joinedAt DateTime @default(now())
|
|
|
|
|
|
isActive Boolean @default(true)
|
|
|
|
|
|
|
|
|
|
|
|
user User @relation(fields: [userId], references: [id])
|
|
|
|
|
|
room Room @relation(fields: [roomId], references: [id], onDelete: Cascade)
|
|
|
|
|
|
|
|
|
|
|
|
@@unique([userId, roomId])
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
enum ParticipantRole {
|
|
|
|
|
|
HOST
|
|
|
|
|
|
PLAYER
|
|
|
|
|
|
SPECTATOR
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-06 20:12:36 +00:00
|
|
|
|
enum UserRole {
|
|
|
|
|
|
USER
|
|
|
|
|
|
ADMIN
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-03 14:07:04 +00:00
|
|
|
|
model QuestionPack {
|
|
|
|
|
|
id String @id @default(uuid())
|
|
|
|
|
|
name String
|
|
|
|
|
|
description String
|
|
|
|
|
|
category String
|
|
|
|
|
|
isPublic Boolean @default(false)
|
|
|
|
|
|
createdBy String
|
|
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
|
|
updatedAt DateTime @updatedAt
|
|
|
|
|
|
|
|
|
|
|
|
questions Json // Массив вопросов с ответами
|
|
|
|
|
|
questionCount Int @default(0)
|
|
|
|
|
|
timesUsed Int @default(0)
|
|
|
|
|
|
rating Float @default(0)
|
|
|
|
|
|
|
|
|
|
|
|
creator User @relation(fields: [createdBy], references: [id])
|
|
|
|
|
|
rooms Room[]
|
2026-01-08 17:56:00 +00:00
|
|
|
|
roomPacks RoomPack[] @relation("RoomPackSource")
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
model RoomPack {
|
|
|
|
|
|
id String @id @default(uuid())
|
|
|
|
|
|
roomId String @unique
|
|
|
|
|
|
name String
|
|
|
|
|
|
description String @default("")
|
|
|
|
|
|
sourcePackId String?
|
|
|
|
|
|
questions Json @default("[]")
|
|
|
|
|
|
questionCount Int @default(0)
|
|
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
|
|
updatedAt DateTime @updatedAt
|
|
|
|
|
|
deletedAt DateTime?
|
|
|
|
|
|
|
|
|
|
|
|
room Room @relation(fields: [roomId], references: [id], onDelete: Cascade)
|
|
|
|
|
|
sourcePack QuestionPack? @relation("RoomPackSource", fields: [sourcePackId], references: [id])
|
|
|
|
|
|
|
|
|
|
|
|
@@index([roomId])
|
|
|
|
|
|
@@index([sourcePackId])
|
2026-01-03 14:07:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
model GameHistory {
|
|
|
|
|
|
id String @id @default(uuid())
|
|
|
|
|
|
roomId String @unique
|
|
|
|
|
|
roomCode String
|
|
|
|
|
|
questionPackId String
|
|
|
|
|
|
startedAt DateTime
|
|
|
|
|
|
finishedAt DateTime
|
|
|
|
|
|
|
|
|
|
|
|
players Json // { userId: { name, score, rank } }
|
|
|
|
|
|
statistics Json // Детальная статистика игры
|
|
|
|
|
|
timeline Json // История событий игры
|
|
|
|
|
|
|
|
|
|
|
|
room Room @relation(fields: [roomId], references: [id], onDelete: Cascade)
|
|
|
|
|
|
}
|
2026-01-06 20:12:36 +00:00
|
|
|
|
|
|
|
|
|
|
model AdminAuthCode {
|
|
|
|
|
|
id String @id @default(uuid())
|
|
|
|
|
|
code String @unique
|
|
|
|
|
|
telegramId String?
|
|
|
|
|
|
status CodeStatus @default(PENDING)
|
|
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
|
|
expiresAt DateTime
|
|
|
|
|
|
usedAt DateTime?
|
|
|
|
|
|
|
|
|
|
|
|
@@index([code])
|
|
|
|
|
|
@@index([telegramId])
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
enum CodeStatus {
|
|
|
|
|
|
PENDING
|
|
|
|
|
|
CLAIMED
|
|
|
|
|
|
USED
|
|
|
|
|
|
EXPIRED
|
|
|
|
|
|
}
|
2026-01-09 16:44:33 +00:00
|
|
|
|
|
|
|
|
|
|
model Theme {
|
|
|
|
|
|
id String @id @default(uuid())
|
|
|
|
|
|
name String
|
|
|
|
|
|
isPublic Boolean @default(false)
|
|
|
|
|
|
createdBy String
|
|
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
|
|
updatedAt DateTime @updatedAt
|
|
|
|
|
|
|
|
|
|
|
|
colors Json // { bgPrimary, bgOverlay, bgCard, textPrimary, textSecondary, accentPrimary, etc. }
|
|
|
|
|
|
settings Json // { shadowSm, shadowMd, blurAmount, borderRadius, animationSpeed, etc. }
|
|
|
|
|
|
|
|
|
|
|
|
creator User @relation(fields: [createdBy], references: [id])
|
|
|
|
|
|
}
|