schema.prisma
1.97 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
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
generator client {
provider = "prisma-client-js"
previewFeatures = ["fullTextSearch"]
}
datasource db {
provider = "postgres"
url = env("DATABASE_URL")
}
model User {
id String @id @unique @default(dbgenerated("gen_random_uuid()")) @db.Uuid
email String @unique
name String
password String
role Role @default(USER)
posts Post[]
postlikes PostLike[]
commentlikes CommentLike[]
comments Comment[]
}
model Post {
id Int @id @unique @default(autoincrement())
title String
createdAt DateTime @default(now())
private Boolean @default(false)
author User @relation(fields: [authorId], references: [id])
authorId String @db.Uuid
level Level @default(MEDIUM)
explain String
example String
testinput String[]
testoutput String[]
postlikes PostLike[]
comments Comment[]
}
model Comment {
id String @id @unique @default(dbgenerated("gen_random_uuid()")) @db.Uuid
content String
createdAt DateTime @default(now())
author User @relation(fields: [authorId], references: [id])
authorId String @db.Uuid
post Post @relation(fields: [postId], references: [id])
postId Int
commentlikes CommentLike[]
}
model PostLike {
id String @id @unique @default(dbgenerated("gen_random_uuid()")) @db.Uuid
post Post @relation(fields: [postId], references: [id])
postId Int
user User @relation(fields: [userId], references: [id])
userId String @db.Uuid
}
model CommentLike {
id String @id @unique @default(dbgenerated("gen_random_uuid()")) @db.Uuid
comment Comment @relation(fields: [commentId], references: [id])
commentId String @db.Uuid
user User @relation(fields: [userId], references: [id])
userId String @db.Uuid
}
enum Level {
LOW
MEDIUM
HIGH
}
enum Role {
USER
ADMIN
}