forked from lukevella/rallly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.prisma
115 lines (102 loc) · 3.44 KB
/
schema.prisma
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
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
}
model User {
id String @id @default(cuid())
name String
email String @unique() @db.Citext
createdAt DateTime @default(now())
updatedAt DateTime? @updatedAt
polls Poll[]
participants Participant[]
comments Comment[]
}
enum PollType {
date
}
model Poll {
urlId String @id @unique
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
deadline DateTime?
title String
type PollType
description String?
location String?
user User @relation(fields: [userId], references: [id])
userId String
votes Vote[]
verificationCode String
timeZone String?
verified Boolean @default(false)
options Option[]
participants Participant[]
authorName String @default("")
demo Boolean @default(false)
comments Comment[]
links Link[]
legacy Boolean @default(false)
closed Boolean @default(false)
notifications Boolean @default(false)
@@unique([urlId, verificationCode])
}
enum Role {
admin
participant
}
model Link {
urlId String @id @unique
role Role
pollId String
poll Poll @relation(fields: [pollId], references: [urlId], onDelete: Cascade)
createdAt DateTime @default(now())
@@unique([pollId, role])
}
model Participant {
id String @id @default(cuid())
name String
user User? @relation(fields: [userId], references: [id])
userId String?
poll Poll @relation(fields: [pollId], references: [urlId], onDelete: Cascade)
pollId String
votes Vote[]
createdAt DateTime @default(now())
updatedAt DateTime? @updatedAt
@@unique([id, pollId])
}
model Option {
id String @id @default(cuid())
value String
pollId String
poll Poll @relation(fields: [pollId], references: [urlId], onDelete: Cascade)
createdAt DateTime @default(now())
updatedAt DateTime? @updatedAt
votes Vote[]
}
model Vote {
id String @id @default(cuid())
participant Participant @relation(fields: [participantId], references: [id], onDelete: Cascade)
participantId String
option Option @relation(fields: [optionId], references: [id], onDelete: Cascade)
optionId String
poll Poll @relation(fields: [pollId], references: [urlId], onDelete: Cascade)
pollId String
createdAt DateTime @default(now())
updatedAt DateTime? @updatedAt
}
model Comment {
id String @id @default(cuid())
content String
poll Poll @relation(fields:[pollId], references: [urlId], onDelete: Cascade)
pollId String
authorName String
user User? @relation(fields: [userId], references: [id])
userId String?
createdAt DateTime @default(now())
updatedAt DateTime? @updatedAt
@@unique([id, pollId])
}