-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathschema.prisma
101 lines (87 loc) · 3.78 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
generator client {
provider = "prisma-client-js"
previewFeatures = ["interactiveTransactions"]
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model article {
id Int @id @default(autoincrement())
authorId Int
slug String @unique
title String
description String
body String
favoritesCount Int @default(0)
createdAt DateTime @default(now()) @db.Timestamp(6)
updatedAt DateTime @default(now()) @db.Timestamp(6)
user user @relation(fields: [authorId], references: [id])
articleTag articleTag[]
comment comment[]
userArticleFavorite userArticleFavorite[]
@@index([authorId], name: "articleAuthorIdIndex")
}
model articleTag {
id Int @id @default(autoincrement())
articleId Int
tagId Int
article article @relation(fields: [articleId], references: [id])
tag tag @relation(fields: [tagId], references: [id])
@@unique([articleId, tagId], name: "articleTagArticleIdTagIdIndex")
@@index([articleId], name: "articleTagArticleIdIndex")
@@index([tagId], name: "articleTagTagIdIndex")
}
model comment {
id Int @id @default(autoincrement())
authorId Int
articleId Int
body String
createdAt DateTime @default(now()) @db.Timestamp(6)
updatedAt DateTime @default(now()) @db.Timestamp(6)
article article @relation(fields: [articleId], references: [id])
user user @relation(fields: [authorId], references: [id])
}
/// The underlying table does not contain a valid unique identifier and can therefore currently not be handled by the Prisma Client.
model schemaMigrations {
version String
@@ignore
}
model tag {
id Int @id @default(autoincrement())
tag String @unique
articleTag articleTag[]
}
model user {
id Int @id @default(autoincrement())
email String @unique
username String @unique
password String
bio String?
image String?
article article[]
comment comment[]
userArticleFavorite userArticleFavorite[]
userFollow_userTouserFollow_followerId userFollow[] @relation("userTouserFollow_followerId")
userFollow_userTouserFollow_followingId userFollow[] @relation("userTouserFollow_followingId")
}
model userArticleFavorite {
id Int @id @default(autoincrement())
userId Int
articleId Int
article article @relation(fields: [articleId], references: [id])
user user @relation(fields: [userId], references: [id])
@@unique([userId, articleId], name: "userArticleFavoriteUserIdArticleIdIndex")
@@index([articleId], name: "userArticleFavoriteArticleIdIndex")
@@index([userId], name: "userArticleFavoriteUserIdIndex")
}
model userFollow {
id Int @id @default(autoincrement())
followerId Int
followingId Int
user_userTouserFollow_followerId user @relation("userTouserFollow_followerId", fields: [followerId], references: [id])
user_userTouserFollow_followingId user @relation("userTouserFollow_followingId", fields: [followingId], references: [id])
@@unique([followerId, followingId], name: "userFollowFollowerIdFollowingIdIndex")
@@index([followerId], name: "userFollowFollowerIdIndex")
@@index([followingId], name: "userFollowFollowingIdIndex")
}