-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.prisma
More file actions
200 lines (177 loc) · 5.54 KB
/
schema.prisma
File metadata and controls
200 lines (177 loc) · 5.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgres"
url = env("DATABASE_URL")
}
model Account {
id String @id @default(cuid())
userId String
type String
provider String
providerAccountId String
refresh_token String?
access_token String?
expires_at Int?
token_type String?
scope String?
id_token String?
session_state String?
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@unique([provider, providerAccountId])
@@map("accounts")
}
model Session {
id String @id @default(cuid())
sessionToken String @unique
userId String
expires DateTime
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@map("sessions")
}
model User {
id String @id @default(cuid())
name String
discriminator String?
email String? @unique
emailVerified DateTime?
image String?
role Role @default(USER)
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
clubId String?
accounts Account[]
sessions Session[]
club Club? @relation(fields: [clubId], references: [id])
@@map("users")
}
model VerificationToken {
identifier String
token String @unique
expires DateTime
@@unique([identifier, token])
@@map("verificationtokens")
}
model Club {
id String @id @default(uuid())
name String
slug String @unique
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
invite Invite[]
teams Team[]
users User[]
}
model Invite {
id String @id @default(uuid())
clubId String?
expiresAt DateTime?
redeemedAt DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
club Club? @relation(fields: [clubId], references: [id])
}
model Team {
id String @id @default(uuid())
name String
slug String
leagueId String
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
clubId String?
availability Availability[]
matchesAsBlueTeam Match[] @relation("blueTeam")
matchesAsRedTeam Match[] @relation("redTeam")
club Club? @relation(fields: [clubId], references: [id], onDelete: Cascade)
league League @relation(fields: [leagueId], references: [id], onDelete: Cascade)
player Player[]
stat Stat[]
@@unique([leagueId, name])
@@unique([leagueId, slug])
}
model Player {
id String @id @default(uuid())
name String
handle String?
teamId String
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
team Team @relation(fields: [teamId], references: [id], onDelete: Cascade)
stat Stat[]
@@unique([teamId, name])
}
model Stat {
id String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
match Match @relation(fields: [matchId], references: [id])
player Player @relation(fields: [playerId], references: [id])
team Team @relation(fields: [teamId], references: [id])
teamId String
playerId String
character String?
stock Int?
win Boolean
matchId String
}
model Game {
id String @id @default(uuid())
name String @unique
slug String @unique
leagues League[]
}
model League {
id String @id @default(uuid())
name String
slug String @unique
seasonStart DateTime @default(now())
seasonEnd DateTime @default(now())
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
gameId String
minimumMatchTime Int?
availability Availability[]
game Game @relation(fields: [gameId], references: [id])
matches Match[]
teams Team[]
}
model Match {
id String @id @default(uuid())
blueTeamId String
redTeamId String
blueScore Int?
redScore Int?
date DateTime
leagueId String
isPlayoff Boolean @default(false)
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
blueTeam Team @relation("blueTeam", fields: [blueTeamId], references: [id])
league League @relation(fields: [leagueId], references: [id])
redTeam Team @relation("redTeam", fields: [redTeamId], references: [id])
stat Stat[]
}
model Availability {
id String @id @default(uuid())
teamId String
leagueId String
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
league League @relation(fields: [leagueId], references: [id])
team Team @relation(fields: [teamId], references: [id], onDelete: Cascade)
times AvailableTimes[]
@@unique([teamId, leagueId])
}
model AvailableTimes {
id String @id @default(uuid())
createdAt DateTime @default(now())
availabilityId String
endTime DateTime
startTime DateTime
availability Availability @relation(fields: [availabilityId], references: [id])
}
enum Role {
USER
ADMIN
}