-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.prisma
226 lines (187 loc) · 5.06 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
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
generator supabase {
provider = "node ../dist/cli.js"
output = "database.ts" // Optional: Defaults to ./prisma/database.ts
enableDocumentation = true // Optional: Defaults to true
previewFeatures = ["views"]
}
/// User
///
/// This model represents a user in the system.
/// It stores essential information about each user, including their unique identifier,
/// email address, name, role, and associated posts.
/// Users can have multiple posts and are assigned a specific role (USER or ADMIN).
model User {
/// The unique identifier for the user.
/// This UUID is automatically generated when a new user is created.
/// It serves as the primary key for the User model and is used to
/// establish relationships with other models, such as Post.
id String @id @default(uuid()) @db.Uuid
/// The user's email address.
email String @unique
/// The user's name.
name String?
/// The user's role.
role UserRole @default(USER)
/// The user's posts.
posts Post[]
}
/// Post
///
/// This model represents a blog post or article in the system.
/// It contains information about each post, including its unique identifier,
/// title, content, publication status, and the author who wrote it.
model Post {
/// The unique identifier for the post.
id String @id @default(uuid()) @db.Uuid
/// The title of the post.
title String
/// The content of the post.
/// This optional field contains the main body or text of the blog post.
/// It can store formatted text, allowing for rich content including
/// paragraphs, headings, lists, and potentially embedded media.
content String?
/// Whether the post is published.
published Boolean @default(false)
/// The user who wrote the post.
authorId String @db.Uuid
/// The status of the post.
status PostStatus @default(DRAFT)
/// The user who wrote the post.
author User @relation(fields: [authorId], references: [id])
}
/// User View
///
/// This view contains the user's role.
view UserView {
id String @id @default(uuid()) @db.Uuid
role UserRole
// TEST ENUMS
noDoc NoDoc
memberOnlyDoc MemberOnlyDoc
parentOnlyDoc ParentOnlyDoc
mixedDoc MixedDoc
markdownDoc MarkdownDoc
specialContentDoc SpecialContentDoc
/// Make sure this gets added too
emptyVariations EmptyVariations
}
/// User role
///
/// This enum defines the possible roles a user can have in the system.
/// It is used to determine the level of access and permissions for each user.
enum UserRole {
/// A regular user.
USER
/// An administrator.
/// Users with this role have elevated privileges within the application.
/// Administrators can typically access all features, manage other users,
/// and perform system-wide operations that are not available to regular users.
ADMIN
}
/// Post status
///
/// This enum defines the possible statuses a post can have in the system.
/// It is used to determine the publication status of a post.
enum PostStatus {
/// A draft post.
DRAFT
/// A published post
PUBLISHED
}
// Test Cases
/// No documentation at all
enum NoDoc {
VALUE_1
VALUE_2
}
enum MemberOnlyDoc {
/// Value 1 description
VALUE_1
/// Value 2 description
VALUE_2
}
/// Parent only documentation
/// This enum demonstrates documentation only at the enum level
enum ParentOnlyDoc {
VALUE_1
VALUE_2
}
/// Mixed documentation patterns
/// Tests various documentation combinations
enum MixedDoc {
/// Documented value
VALUE_1
// Regular comment (not doc comment)
VALUE_2
VALUE_3 // Inline comment
/// Doc with inline // comment
VALUE_4 // With extra comment
}
/// Documentation with markdown formatting
/// Demonstrates **bold**, *italic*, and `code`
/// - First point
/// - Second point
/// # Heading 1
/// ## Heading 2
enum MarkdownDoc {
/// List item:
LIST_ITEM
/// # Heading 1
/// ## Heading 2
/// > Blockquote
FORMATTED_TEXT
}
/// Documentation with special content
enum SpecialContentDoc {
/// Contains URLs: https://example.com
/// And email: [email protected]
WITH_LINKS
/// Contains *special* characters:
/// @#$%^&*()_+ and émojis 🎉 ⭐️
SPECIAL_CHARS
/// ```typescript
/// const code = 'example';
/// ```
WITH_CODE_BLOCK
/// Contains "quotes" and 'apostrophes'
/// And line breaks
/// And multiple spaces
WITH_FORMATTING
}
/// Empty variations
enum EmptyVariations {
///
EMPTY_DOC
///
///
MULTI_EMPTY_DOC
ALT_DOC_STYLE
// Regular comment
REGULAR_COMMENT
}
/// Mixed length documentation
enum MixedLengthDoc {
/// Short
SHORT
/// This is a much longer documentation string that extends beyond
/// the typical length of a documentation comment and includes
/// multiple lines of detailed description about the enum value
LONG
/// Medium length
/// With two lines
MEDIUM
}
/// Demonstrates documentation with various indentation
enum IndentationDoc {
/// Indented documentation
/// Also indented
/// More indentation
INDENTED_VALUE
/// Non-indented doc
/// For comparison
NORMAL_VALUE
}