schema.prisma
1.23 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
// 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"
}
datasource db {
provider = "postgres"
url = env("DATABASE_URL")
}
model User {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid @unique
email String @unique
name String
password String
role Role @default(USER)
posts Post[]
comments Comment[]
}
model Post {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid @unique
title String
createdAt DateTime @default(now())
private Boolean @default(true)
author User @relation(fields: [authorId], references: [id])
authorId String @db.Uuid
level Level @default(MEDIUM)
content String
comments Comment[]
}
model Comment {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid @unique
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 String @db.Uuid
}
enum Level {
LOW
MEDIUM
HIGH
}
enum Role {
USER
ADMIN
}