Create schema.prisma
Browse files- schema.prisma +108 -0
schema.prisma
ADDED
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
generator client {
|
2 |
+
provider = "prisma-client-js"
|
3 |
+
}
|
4 |
+
|
5 |
+
datasource db {
|
6 |
+
provider = "postgresql"
|
7 |
+
url = env("DATABASE_URL")
|
8 |
+
}
|
9 |
+
|
10 |
+
model User {
|
11 |
+
id Int @id @default(autoincrement())
|
12 |
+
name String
|
13 |
+
voiceId String?
|
14 |
+
voiceLanguage String?
|
15 |
+
audioUrl String?
|
16 |
+
createdAt DateTime @default(now())
|
17 |
+
updatedAt DateTime @updatedAt
|
18 |
+
groups GroupMember[]
|
19 |
+
invitations Invitation[] @relation("InvitedUser")
|
20 |
+
createdGroups Group[] @relation("GroupCreator")
|
21 |
+
}
|
22 |
+
|
23 |
+
model Group {
|
24 |
+
id Int @id @default(autoincrement())
|
25 |
+
name String
|
26 |
+
inviteCode String @unique
|
27 |
+
status String @default("WAITING")
|
28 |
+
createdAt DateTime @default(now())
|
29 |
+
updatedAt DateTime @updatedAt
|
30 |
+
creator User @relation("GroupCreator", fields: [creatorId], references: [id])
|
31 |
+
creatorId Int
|
32 |
+
members GroupMember[]
|
33 |
+
invitations Invitation[]
|
34 |
+
gameState GameState?
|
35 |
+
}
|
36 |
+
|
37 |
+
model GroupMember {
|
38 |
+
id Int @id @default(autoincrement())
|
39 |
+
group Group @relation(fields: [groupId], references: [id])
|
40 |
+
groupId Int
|
41 |
+
user User @relation(fields: [userId], references: [id])
|
42 |
+
userId Int
|
43 |
+
joinedAt DateTime @default(now())
|
44 |
+
isReady Boolean @default(false)
|
45 |
+
|
46 |
+
@@unique([groupId, userId])
|
47 |
+
}
|
48 |
+
|
49 |
+
model Invitation {
|
50 |
+
id Int @id @default(autoincrement())
|
51 |
+
group Group @relation(fields: [groupId], references: [id])
|
52 |
+
groupId Int
|
53 |
+
user User? @relation("InvitedUser", fields: [userId], references: [id])
|
54 |
+
userId Int?
|
55 |
+
email String?
|
56 |
+
status InvitationStatus @default(PENDING)
|
57 |
+
createdAt DateTime @default(now())
|
58 |
+
expiresAt DateTime?
|
59 |
+
}
|
60 |
+
|
61 |
+
model GameState {
|
62 |
+
id Int @id @default(autoincrement())
|
63 |
+
group Group @relation(fields: [groupId], references: [id])
|
64 |
+
groupId Int @unique
|
65 |
+
status GameStatus @default(WAITING)
|
66 |
+
stolenVoicePlayerId Int?
|
67 |
+
currentRound Int @default(0)
|
68 |
+
startedAt DateTime?
|
69 |
+
endedAt DateTime?
|
70 |
+
rounds GameRound[]
|
71 |
+
}
|
72 |
+
|
73 |
+
model GameRound {
|
74 |
+
id Int @id @default(autoincrement())
|
75 |
+
gameState GameState @relation(fields: [gameStateId], references: [id])
|
76 |
+
gameStateId Int
|
77 |
+
roundNumber Int
|
78 |
+
speakerId Int
|
79 |
+
guesses Guess[]
|
80 |
+
startedAt DateTime @default(now())
|
81 |
+
endedAt DateTime?
|
82 |
+
}
|
83 |
+
|
84 |
+
model Guess {
|
85 |
+
id Int @id @default(autoincrement())
|
86 |
+
gameRound GameRound @relation(fields: [gameRoundId], references: [id])
|
87 |
+
gameRoundId Int
|
88 |
+
guesserId Int
|
89 |
+
guessedId Int
|
90 |
+
isCorrect Boolean
|
91 |
+
createdAt DateTime @default(now())
|
92 |
+
}
|
93 |
+
|
94 |
+
enum InvitationStatus {
|
95 |
+
PENDING
|
96 |
+
ACCEPTED
|
97 |
+
DECLINED
|
98 |
+
EXPIRED
|
99 |
+
}
|
100 |
+
|
101 |
+
enum GameStatus {
|
102 |
+
WAITING
|
103 |
+
ANSWERS
|
104 |
+
DEBATE
|
105 |
+
VOTE
|
106 |
+
FINISHED
|
107 |
+
CANCELLED
|
108 |
+
}
|