-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.prisma
More file actions
159 lines (132 loc) · 3.62 KB
/
Copy pathschema.prisma
File metadata and controls
159 lines (132 loc) · 3.62 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
generator client {
provider = "prisma-client"
output = "../src/lib/prisma"
}
datasource db {
provider = "postgresql"
}
model User {
id String @id @default(cuid())
name String
email String @unique
emailVerified Boolean @default(false)
image String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
accounts Account[]
sessions Session[]
profile UserProfile?
apiKeys ApiKey[]
posts Post[]
}
model Session {
id String @id @default(cuid())
token String @unique
userId String
expiresAt DateTime
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
ipAddress String?
userAgent String?
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@index([userId])
}
model Account {
id String @id @default(cuid())
userId String
providerId String
accountId String
accessToken String?
refreshToken String?
idToken String?
accessTokenExpiresAt DateTime?
refreshTokenExpiresAt DateTime?
scope String?
password String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@index([userId])
}
model Verification {
id String @id @default(cuid())
identifier String
value String
expiresAt DateTime
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@index([identifier])
}
model UserProfile {
id String @id @default(cuid())
role Role @default(AGENT)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
userId String @unique
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
}
enum Role {
ADMIN
AUTHOR
AGENT
GUEST
}
model ApiKey {
id String @id @default(cuid())
key String @unique
name String
userId String
createdAt DateTime @default(now())
expiresAt DateTime?
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
}
model Post {
id String @id @default(cuid())
title String
slug String @unique
bodyMarkdown String
bodyHtml String
visibility Visibility @default(PUBLIC)
authorId String
publishedAt DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
author User @relation(fields: [authorId], references: [id], onDelete: Cascade)
metadata PostMetadata?
pageViews PageView[]
@@index([title(ops: raw("gin_trgm_ops"))], type: Gin, name: "Post_title_trgm_idx")
@@index([slug(ops: raw("gin_trgm_ops"))], type: Gin, name: "Post_slug_trgm_idx")
}
enum Visibility {
PUBLIC
PRIVATE
UNLISTED
DRAFT
}
model PostMetadata {
id String @id @default(cuid())
seoDescription String?
coverImage String?
tags String[]
postId String @unique
post Post @relation(fields: [postId], references: [id], onDelete: Cascade)
@@index([tags], type: Gin, name: "PostMetadata_tags_gin_idx")
}
model SiteSettings {
id String @id @default(cuid())
key String @unique
value String
}
model PageView {
id String @id @default(cuid())
path String
referrer String?
userAgent String?
ipHash String?
postId String?
createdAt DateTime @default(now())
post Post? @relation(fields: [postId], references: [id], onDelete: SetNull)
@@index([path])
@@index([postId])
@@index([createdAt])
}