-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.prisma
More file actions
547 lines (465 loc) · 13.6 KB
/
schema.prisma
File metadata and controls
547 lines (465 loc) · 13.6 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
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
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "rhel-openssl-1.0.x"]
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model SiteSettings {
id String @id @default(cuid())
siteName String
siteDescription String
siteLogo String
siteFavicon String
siteTheme String
siteLanguage String
siteBotEnabled Boolean @default(false)
siteAdminUserEmails String[]
siteModeratorUserEmails String[]
siteRegistrationEnabled Boolean @default(false)
}
model User {
id String @id @default(cuid())
email String? @unique
password String? // hashed password for credentials auth
username String? @unique
name String?
image String?
emailVerified DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
// Enhanced profile fields
bio String?
location String?
website String?
githubUrl String?
twitterUrl String?
skills String[] // Array of skills/technologies
joinedAt DateTime @default(now())
// Role/permission system
role Role @default(MEMBER)
isActive Boolean @default(true)
isBanned Boolean @default(false)
bannedAt DateTime?
bannedReason String?
// Activity tracking
lastLoginAt DateTime?
profileViews Int @default(0)
lastSeenAt DateTime?
// Discord bot access (only if Discord linked)
discordId String? @unique // Discord user ID for bot dashboard access
discordTag String? // Discord username for display
canAccessBot Boolean @default(false) // Permission for bot dashboard
// Relations
accounts Account[]
sessions Session[]
newsPosts NewsPost[]
events Event[]
achievements UserAchievement[]
profileViewsGiven ProfileView[] @relation("ProfileViewer")
profileViewsReceived ProfileView[] @relation("ProfileOwner")
EventParticipant EventParticipant[]
posts Post[]
comments Comment[]
postLikes PostLike[]
bookmarks Bookmark[]
postShares PostShare[]
postReports PostReport[]
postRevisions PostRevision[]
}
model Account {
id String @id @default(cuid())
userId String
type String
provider String
providerAccountId String
refresh_token String? @db.Text
access_token String? @db.Text
expires_at Int?
token_type String?
scope String?
id_token String? @db.Text
session_state String?
// Account linking enhancement
linkedAt DateTime @default(now())
isVerified Boolean @default(false)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@unique([provider, providerAccountId])
}
model Session {
id String @id @default(cuid())
sessionToken String @unique
userId String
expires DateTime
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
}
model VerificationToken {
identifier String
token String @unique
expires DateTime
@@unique([identifier, token])
}
// Enhanced NewsPost model
model NewsPost {
id String @id @default(cuid())
title String
content String
excerpt String? // Short description
published Boolean @default(false)
publishedAt DateTime?
tags String[] // Array of tags
featured Boolean @default(false)
viewCount Int @default(0)
order Int @default(0)
contentType ContentType @default(MARKDOWN)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
authorId String
author User @relation(fields: [authorId], references: [id])
@@index([authorId])
@@index([published])
@@index([featured])
@@index([order])
}
// Community Events/Challenges
model Event {
id String @id @default(cuid())
title String
description String
excerpt String?
startDate DateTime
endDate DateTime?
eventType EventType @default(GENERAL)
isActive Boolean @default(true)
maxParticipants Int?
participantCount Int @default(0)
prizes String[] // Array of prizes
rules String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
createdBy String
creator User @relation(fields: [createdBy], references: [id])
participants EventParticipant[]
@@index([createdBy])
@@index([startDate])
@@index([eventType])
}
model EventParticipant {
id String @id @default(cuid())
eventId String
userId String
joinedAt DateTime @default(now())
status ParticipantStatus @default(ACTIVE)
event Event @relation(fields: [eventId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@unique([eventId, userId])
@@index([eventId])
@@index([userId])
}
// Achievement system
model Achievement {
id String @id @default(cuid())
name String @unique
description String
iconUrl String?
category AchievementCategory @default(GENERAL)
points Int @default(0)
isActive Boolean @default(true)
createdAt DateTime @default(now())
userAchievements UserAchievement[]
@@index([category])
}
model UserAchievement {
id String @id @default(cuid())
userId String
achievementId String
earnedAt DateTime @default(now())
progress Int @default(100) // Percentage complete
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
achievement Achievement @relation(fields: [achievementId], references: [id], onDelete: Cascade)
@@unique([userId, achievementId])
@@index([userId])
@@index([achievementId])
}
// Profile view tracking
model ProfileView {
id String @id @default(cuid())
viewerId String? // null for anonymous views
profileId String
viewedAt DateTime @default(now())
ipAddress String? // For anonymous tracking
userAgent String?
viewer User? @relation("ProfileViewer", fields: [viewerId], references: [id], onDelete: SetNull)
profile User @relation("ProfileOwner", fields: [profileId], references: [id], onDelete: Cascade)
@@index([profileId])
@@index([viewerId])
@@index([viewedAt])
}
// New model for dynamic categorization of posts (write-ups, announcements, CVEs, etc.)
model PostType {
id String @id @default(cuid())
name String @unique
description String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
posts Post[]
}
model Post {
id String @id @default(cuid())
title String
slug String @unique
content String @db.Text // Full post content in markdown/HTML
excerpt String? @db.Text // Short description/summary
// Publishing & Status
status PostStatus @default(DRAFT)
publishedAt DateTime?
scheduledAt DateTime? // For scheduled publishing
// Metadata
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
// Author information
authorId String
author User @relation(fields: [authorId], references: [id], onDelete: Cascade)
// Content categorization
category PostCategory
tags String[] // Array of tags for filtering
// Relation to dynamic post type
typeId String?
type PostType? @relation(fields: [typeId], references: [id], onDelete: SetNull)
// Security-specific fields
vulnerabilityType String? // e.g., "XSS", "SQL Injection", "Buffer Overflow"
severity Severity? // Critical, High, Medium, Low
cveId String? // CVE identifier if applicable
affectedSystems String[] // Systems/software affected
patchStatus PatchStatus? // Available, Pending, None
// Technical details
exploitCode String? @db.Text // Code examples/proof of concept
remediation String? @db.Text // Fix/mitigation steps
references String[] // External links/references
// Engagement metrics
viewCount Int @default(0)
likeCount Int @default(0)
commentCount Int @default(0)
shareCount Int @default(0)
// SEO & Discovery
metaTitle String?
metaDescription String?
featuredImage String? // URL to featured image
imageAlt String? // Alt text for featured image
// Content flags
isVerified Boolean @default(false) // Verified by moderators
isFeatured Boolean @default(false) // Featured content
isPinned Boolean @default(false) // Pinned posts
allowComments Boolean @default(true)
isArchived Boolean @default(false)
// Approval status
approved Boolean @default(false)
// Moderation
reportCount Int @default(0)
isReported Boolean @default(false)
moderationNotes String? @db.Text
// Analytics tracking
lastViewedAt DateTime?
peakViewsDate DateTime?
avgTimeOnPage Float? // Average time spent reading (seconds)
// Version control (for tracking edits)
version Int @default(1)
editReason String? // Reason for last edit
// Relations
comments Comment[]
likes PostLike[]
bookmarks Bookmark[]
shares PostShare[]
reports PostReport[]
revisions PostRevision[]
@@index([authorId])
@@index([status])
@@index([category])
@@index([publishedAt])
@@index([createdAt])
@@index([vulnerabilityType])
@@index([severity])
@@index([viewCount])
@@index([likeCount])
@@index([typeId])
@@map("posts")
}
// Supporting models for relations
model Comment {
id String @id @default(cuid())
content String @db.Text
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
// Relations
postId String
post Post @relation(fields: [postId], references: [id], onDelete: Cascade)
authorId String
author User @relation(fields: [authorId], references: [id], onDelete: Cascade)
// Nested comments
parentId String?
parent Comment? @relation("CommentReplies", fields: [parentId], references: [id])
replies Comment[] @relation("CommentReplies")
// Moderation
isDeleted Boolean @default(false)
isEdited Boolean @default(false)
@@index([postId])
@@index([authorId])
@@index([createdAt])
@@map("comments")
}
model PostLike {
id String @id @default(cuid())
createdAt DateTime @default(now())
// Relations
postId String
post Post @relation(fields: [postId], references: [id], onDelete: Cascade)
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@unique([postId, userId])
@@index([postId])
@@index([userId])
@@map("post_likes")
}
model Bookmark {
id String @id @default(cuid())
createdAt DateTime @default(now())
// Relations
postId String
post Post @relation(fields: [postId], references: [id], onDelete: Cascade)
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@unique([postId, userId])
@@index([postId])
@@index([userId])
@@map("bookmarks")
}
model PostShare {
id String @id @default(cuid())
platform String // "twitter", "linkedin", "discord", etc.
createdAt DateTime @default(now())
// Relations
postId String
post Post @relation(fields: [postId], references: [id], onDelete: Cascade)
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@index([postId])
@@index([userId])
@@map("post_shares")
}
model PostReport {
id String @id @default(cuid())
reason ReportReason
details String? @db.Text
createdAt DateTime @default(now())
resolved Boolean @default(false)
// Relations
postId String
post Post @relation(fields: [postId], references: [id], onDelete: Cascade)
reporterId String
reporter User @relation(fields: [reporterId], references: [id], onDelete: Cascade)
@@index([postId])
@@index([reporterId])
@@map("post_reports")
}
model PostRevision {
id String @id @default(cuid())
title String
content String @db.Text
changeReason String? @db.Text
createdAt DateTime @default(now())
// Relations
postId String
post Post @relation(fields: [postId], references: [id], onDelete: Cascade)
authorId String
author User @relation(fields: [authorId], references: [id], onDelete: Cascade)
@@index([postId])
@@index([createdAt])
@@map("post_revisions")
}
// Enums
enum Role {
ADMIN
MODERATOR
MEMBER
GUEST
}
enum ContentType {
MARKDOWN
HTML
RICH_TEXT
}
enum EventType {
GENERAL
CTF
CHALLENGE
WORKSHOP
COMPETITION
MEETUP
}
enum ParticipantStatus {
ACTIVE
WITHDRAWN
COMPLETED
DISQUALIFIED
}
enum AchievementCategory {
GENERAL
PARTICIPATION
SKILL
CONTRIBUTION
MILESTONE
SPECIAL
}
enum ReportReason {
SPAM
INAPPROPRIATE_CONTENT
MISINFORMATION
COPYRIGHT_VIOLATION
HARASSMENT
ILLEGAL_CONTENT
MALICIOUS_CODE
OTHER
}
enum PostStatus {
DRAFT
PUBLISHED
UNPUBLISHED
SCHEDULED
ARCHIVED
DELETED
}
enum PostCategory {
VULNERABILITY_RESEARCH
EXPLOIT_DEVELOPMENT
MALWARE_ANALYSIS
PENETRATION_TESTING
SECURITY_TOOLS
INCIDENT_RESPONSE
THREAT_INTELLIGENCE
REVERSE_ENGINEERING
CRYPTOGRAPHY
NETWORK_SECURITY
WEB_SECURITY
MOBILE_SECURITY
CLOUD_SECURITY
TUTORIAL
NEWS
OPINION
CASE_STUDY
OTHER
}
enum Severity {
CRITICAL
HIGH
MEDIUM
LOW
INFORMATIONAL
}
enum PatchStatus {
AVAILABLE
PENDING
PARTIAL
NONE
UNKNOWN
}