-
Notifications
You must be signed in to change notification settings - Fork 2
/
schema.prisma
51 lines (46 loc) · 1.43 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
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model Brand {
id String @id @default(uuid())
name String @unique
createdAt DateTime @default(now()) @db.Timestamp(6)
posts Post[]
@@map("brands")
}
model Post {
id String @id @default(uuid())
title String @unique @db.VarChar(255)
authorId String
brandId String?
description String?
isPublished Boolean @default(false)
createdAt DateTime @default(now()) @db.Timestamp(6)
brand Brand? @relation(fields: [brandId], references: [id], onDelete: Cascade)
author User @relation(fields: [authorId], references: [id], onDelete: Cascade)
comments Comment[]
@@map("posts")
}
model User {
id String @id @default(uuid())
name String @unique @db.VarChar(255)
email String @unique @db.VarChar(255)
createdAt DateTime @default(now()) @db.Timestamp(6)
posts Post[]
comments Comment[]
@@map("users")
}
model Comment {
id String @id @default(uuid())
text String? @db.VarChar(255)
postId String
authorId String
createdAt DateTime @default(now()) @db.Timestamp(6)
author User @relation(fields: [authorId], references: [id], onDelete: Cascade)
post Post? @relation(fields: [postId], references: [id], onDelete: Cascade)
@@map("comments")
}