-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathschema.prisma
101 lines (81 loc) · 2.54 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
// https://pris.ly/d/prisma-schema
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
output = "./node_modules/.prisma/client"
}
model Site {
id String @id @default(cuid())
hostname String @unique
owner User @relation(fields: [owner_id], references: [id])
owner_id String
posts Post[]
created_at DateTime @default(now())
updated_at DateTime @updatedAt
@@map("sites")
CommentVote CommentVote[]
}
model User {
id String @id @default(cuid())
email String @unique
username String @unique
password String
sites Site[]
comments Comment[]
created_at DateTime @default(now())
updated_at DateTime @updatedAt
@@map("users")
CommentVote CommentVote[]
}
model Comment {
id String @id @default(cuid())
parent Comment? @relation(fields: [parent_comment_id], references: [id])
author User? @relation(fields: [author_id], references: [id])
anon_author_name String?
body String @default("")
post Post @relation(fields: [post_id], references: [id])
post_id String
created_at DateTime @default(now())
updated_at DateTime @updatedAt
replies Comment[] @relation("CommentToComment")
parent_comment_id String?
author_id String?
@@map("comments")
CommentVote CommentVote[]
}
model CommentVote {
id String @id @default(cuid())
user User @relation(fields: [user_id], references: [id])
user_id String
comment Comment @relation(fields: [comment_id], references: [id])
comment_id String
site Site @relation(fields: [site_id], references: [id])
site_id String
post Post @relation(fields: [post_id], references: [id])
post_id String
value Int
@@unique([comment_id, user_id])
@@map("comment_votes")
}
// Tracks the state of the leaf nodes on a per-post basis
model CommentTreeState {
post Post @relation(fields: [post_id], references: [id])
post_id String @id
comment_tree_leafs Json // ["123", "345", "545"]
@@map("comment_tree_state")
}
model Post {
id String @id @default(cuid())
url_slug String @unique
site Site @relation(fields: [site_id], references: [id])
site_id String
comments Comment[]
created_at DateTime @default(now())
updated_at DateTime @updatedAt
@@map("posts")
CommentVote CommentVote[]
CommentTreeState CommentTreeState[]
}