mirror of
https://github.com/hknsh/project-knedita.git
synced 2024-11-28 17:41:15 +00:00
95 lines
No EOL
3.1 KiB
Text
95 lines
No EOL
3.1 KiB
Text
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
model User {
|
|
id String @id @default(uuid())
|
|
displayName String?
|
|
username String @unique
|
|
email String @unique
|
|
password String
|
|
posts Post[]
|
|
profileImage String?
|
|
likedPosts PostLike[]
|
|
likedComments CommentLike[]
|
|
followers Follows[] @relation("following")
|
|
following Follows[] @relation("follower")
|
|
postComments Comments[]
|
|
fromNotifications Notifications[] @relation("fromNotifications")
|
|
toNotifications Notifications[] @relation("toNotifications")
|
|
socketId String?
|
|
createdAt DateTime @default(now())
|
|
}
|
|
|
|
model Post {
|
|
id String @id @default(uuid())
|
|
content String
|
|
authorId String
|
|
author User @relation(fields: [authorId], references: [id], onDelete: Cascade)
|
|
likes PostLike[]
|
|
comments Comments[]
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
}
|
|
|
|
model PostLike {
|
|
id String @id @default(uuid())
|
|
postId String
|
|
post Post @relation(fields: [postId], references: [id], onDelete: Cascade)
|
|
userId String
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
createdAt DateTime @default(now())
|
|
}
|
|
|
|
// I should join these two up? Yeah, but I will not do it since it didn't work on the first time.
|
|
|
|
model CommentLike {
|
|
id String @id @default(uuid())
|
|
commentId String
|
|
comment Comments @relation(fields: [commentId], references: [id], onDelete: Cascade)
|
|
userId String
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
createdAt DateTime @default(now())
|
|
}
|
|
|
|
model Follows {
|
|
follower User @relation("follower", fields: [followerId], references: [id], onDelete: Cascade)
|
|
followerId String
|
|
following User @relation("following", fields: [followingId], references: [id], onDelete: Cascade)
|
|
followingId String
|
|
|
|
@@id([followerId, followingId])
|
|
}
|
|
|
|
model Comments {
|
|
id String @id @default(uuid())
|
|
content String
|
|
userId String
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
postId String
|
|
post Post @relation(fields: [postId], references: [id], onDelete: Cascade)
|
|
likes CommentLike[]
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt @default(now())
|
|
}
|
|
|
|
model Notifications {
|
|
id String @id @default(uuid())
|
|
type NotificationType
|
|
content String
|
|
createdAt DateTime @default(now())
|
|
fromUserId String
|
|
fromUser User? @relation(name: "fromNotifications", fields: [fromUserId], references: [id], onDelete: Cascade)
|
|
toUserId String
|
|
toUser User? @relation(name: "toNotifications", fields: [toUserId], references: [id], onDelete: Cascade)
|
|
}
|
|
|
|
enum NotificationType {
|
|
WARNING
|
|
INFO
|
|
} |