forked from ahaywood/conffomo__redwood
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.prisma
284 lines (263 loc) · 9.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
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
// Don't forget to tell Prisma about your edits to this file using
// `yarn rw prisma migrate dev` or `yarn rw prisma db push`.
// `migrate` is like committing while `push` is for prototyping.
// Read more about both here:
// https://www.prisma.io/docs/orm/prisma-migrate
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
binaryTargets = "native"
}
// Define your own datamodels here and run `yarn redwood prisma migrate dev`
// to create migrations for them and apply to your dev DB.
model User {
id Int @id @default(autoincrement())
firstName String
lastName String
email String @unique
username String @unique
hashedPassword String
salt String
resetToken String?
resetTokenExpiresAt DateTime?
avatar String?
cover String?
bio String?
location String?
website String?
public Boolean @default(true)
directMessages Boolean @default(true) // can receive direct messages
onboarded Boolean @default(false) // whether this user has onboarded
reported Boolean @default(false) // whether someone has reported this account?
likes Like[]
comments Comment[]
bookmarks Bookmark[]
posts Post[]
plans Plan[]
messagesTo Message[] @relation("to_user")
messagesFrom Message[] @relation("from_user")
attendingPlans AttendingPlan[]
mutedBy Muted[] @relation("muted_by") // this is the user doing the muting, should be this user
mutedUser Muted[] @relation("muted_user")
attachments Attachment[]
attending Attending[]
organization Organization[]
blockedByUser Block[] @relation("blocked_by_user")
blockedUser Block[] @relation("blocked_user")
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Bookmark {
id Int @id @default(autoincrement())
post Post @relation(fields: [postId], references: [id])
postId Int
user User @relation(fields: [userId], references: [id])
userId Int
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Like {
id Int @id @default(autoincrement())
user User @relation(fields: [userId], references: [id])
userId Int
Post Post? @relation(fields: [postId], references: [id])
postId Int?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Block {
id Int @id @default(autoincrement())
blockedByUser User @relation(fields: [blockedByUserId], references: [id], name: "blocked_by_user") // user doing the blocking
blockedByUserId Int
blockedUser User @relation(fields: [blockedUserId], references: [id], name: "blocked_user") // user doing the blocking
blockedUserId Int
blockedEvent Event @relation(fields: [eventId], references: [id])
eventId Int
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Organization {
id Int @id @default(autoincrement())
name String
events Event[]
user User @relation(fields: [userId], references: [id]) // owner
userId Int
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Attending {
id Int @id @default(autoincrement())
user User @relation(fields: [userId], references: [id])
userId Int
event Event @relation(fields: [eventId], references: [id])
eventId Int
speaking Boolean @default(false) // true if the user is speaking at this event
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Post {
id Int @id @default(autoincrement())
user User @relation(fields: [userId], references: [id]) // author
userId Int
event Event @relation(fields: [eventId], references: [id])
eventId Int
content String
plan Plan? @relation(fields: [PlanId], references: [id]) // associated to Plans
PlanId Int?
attachments Attachment[]
comments Comment[]
bookmarks Bookmark[]
likes Like[]
reported Boolean @default(false) // if the post has been reported
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
enum AttachmentType {
PHOTO
VIDEO
}
model Attachment {
id Int @id @default(autoincrement())
user User @relation(fields: [userId], references: [id])
userId Int
post Post @relation(fields: [postId], references: [id])
postId Int
alt String?
caption String?
threads Thread[]
type AttachmentType @default(PHOTO)
message Message @relation(fields: [messageId], references: [id])
messageId Int
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Event {
id Int @id @default(autoincrement())
name String
slug String @unique
startDate DateTime
endDate DateTime?
organization Organization? @relation(fields: [organizationId], references: [id])
organizationId Int?
thumbnail String?
cover String?
recommendations Recommendation[]
description String?
location String?
website String?
public Boolean @default(true)
reported Boolean @default(false)
posts Post[]
plans Plan[]
muted Muted[]
attending Attending[]
blocks Block[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Recommendation {
id Int @id @default(autoincrement())
title String
event Event @relation(fields: [eventId], references: [id])
eventId Int
street1 String?
street2 String?
city String?
state String?
zip String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Thread {
id Int @id @default(autoincrement())
comments Comment[]
attachments Attachment @relation(fields: [attachmentId], references: [id])
attachmentId Int
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Comment {
id Int @id @default(autoincrement())
user User @relation(fields: [userId], references: [id]) // author
userId Int
post Post @relation(fields: [postId], references: [id])
postId Int
comment String
thread Thread @relation(fields: [threadId], references: [id])
threadId Int
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Muted {
id Int @id @default(autoincrement())
mutedBy User @relation(fields: [mutedById], references: [id], name: "muted_by") // this is the user doing the muting
mutedById Int
mutedUser User @relation(fields: [mutedUserId], references: [id], name: "muted_user")
mutedUserId Int
mutedEvent Event @relation(fields: [eventId], references: [id])
eventId Int
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Plan {
id Int @id @default(autoincrement())
title String
startDate DateTime @default(now())
endDate DateTime?
thumbnail String?
reported Boolean @default(false)
street1 String?
street2 String?
city String?
state String?
zip String?
public Boolean @default(false)
limit Int? // limit the number of people that can attend
event Event @relation(fields: [eventId], references: [id])
eventId Int
user User @relation(fields: [userId], references: [id]) // author / owner of the plans
userId Int
attendingPlans AttendingPlan[] // list of users planning on attending
posts Post[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
enum AttendingStatus {
INTERESTED
GOING
}
model AttendingPlan {
id Int @id @default(autoincrement())
user User @relation(fields: [userId], references: [id])
userId Int
plan Plan @relation(fields: [planId], references: [id])
planId Int
status AttendingStatus?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Message {
id Int @id @default(autoincrement())
toUser User @relation(fields: [toUserId], references: [id], name: "to_user")
toUserId Int
fromUser User @relation(fields: [fromUserId], references: [id], name: "from_user")
fromUserId Int
message String
edited Boolean @default(false)
attachments Attachment[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Notification {
id Int @id @default(autoincrement())
// postId
// commentId
// type // enum -
// userId
// eventId
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}