| generator client { |
| provider = "prisma-client-js" |
| } |
|
|
| datasource db { |
| provider = "postgresql" |
| url = env("DATABASE_URL") |
| } |
|
|
| model User { |
| id Int @id @default(autoincrement()) |
| name String |
| voiceId String? |
| voiceLanguage String? |
| audioUrl String? |
| createdAt DateTime @default(now()) |
| updatedAt DateTime @updatedAt |
| groups GroupMember[] |
| invitations Invitation[] @relation("InvitedUser") |
| createdGroups Group[] @relation("GroupCreator") |
| } |
|
|
| model Group { |
| id Int @id @default(autoincrement()) |
| name String |
| inviteCode String @unique |
| status String @default("WAITING") |
| createdAt DateTime @default(now()) |
| updatedAt DateTime @updatedAt |
| creator User @relation("GroupCreator", fields: [creatorId], references: [id]) |
| creatorId Int |
| members GroupMember[] |
| invitations Invitation[] |
| gameState GameState? |
| } |
|
|
| model GroupMember { |
| id Int @id @default(autoincrement()) |
| group Group @relation(fields: [groupId], references: [id]) |
| groupId Int |
| user User @relation(fields: [userId], references: [id]) |
| userId Int |
| joinedAt DateTime @default(now()) |
| isReady Boolean @default(false) |
|
|
| @@unique([groupId, userId]) |
| } |
|
|
| model Invitation { |
| id Int @id @default(autoincrement()) |
| group Group @relation(fields: [groupId], references: [id]) |
| groupId Int |
| user User? @relation("InvitedUser", fields: [userId], references: [id]) |
| userId Int? |
| email String? |
| status InvitationStatus @default(PENDING) |
| createdAt DateTime @default(now()) |
| expiresAt DateTime? |
| } |
|
|
| model GameState { |
| id Int @id @default(autoincrement()) |
| group Group @relation(fields: [groupId], references: [id]) |
| groupId Int @unique |
| status GameStatus @default(WAITING) |
| stolenVoicePlayerId Int? |
| currentRound Int @default(0) |
| startedAt DateTime? |
| endedAt DateTime? |
| rounds GameRound[] |
| } |
|
|
| model GameRound { |
| id Int @id @default(autoincrement()) |
| gameState GameState @relation(fields: [gameStateId], references: [id]) |
| gameStateId Int |
| roundNumber Int |
| speakerId Int |
| guesses Guess[] |
| startedAt DateTime @default(now()) |
| endedAt DateTime? |
| } |
|
|
| model Guess { |
| id Int @id @default(autoincrement()) |
| gameRound GameRound @relation(fields: [gameRoundId], references: [id]) |
| gameRoundId Int |
| guesserId Int |
| guessedId Int |
| isCorrect Boolean |
| createdAt DateTime @default(now()) |
| } |
|
|
| enum InvitationStatus { |
| PENDING |
| ACCEPTED |
| DECLINED |
| EXPIRED |
| } |
|
|
| enum GameStatus { |
| WAITING |
| ANSWERS |
| DEBATE |
| VOTE |
| FINISHED |
| CANCELLED |
| } |