2023-06-20 20:05:15 +00:00
|
|
|
generator client {
|
|
|
|
provider = "prisma-client-js"
|
|
|
|
}
|
|
|
|
|
|
|
|
datasource db {
|
|
|
|
provider = "postgresql"
|
|
|
|
url = env("DATABASE_URL")
|
|
|
|
}
|
|
|
|
|
|
|
|
model User {
|
2023-07-25 21:25:43 +00:00
|
|
|
id String @id @default(uuid())
|
|
|
|
displayName String?
|
|
|
|
username String @unique
|
|
|
|
email String @unique
|
|
|
|
password String
|
|
|
|
posts Post[]
|
|
|
|
profileImage String?
|
2023-07-28 13:18:22 +00:00
|
|
|
likedPosts PostLike[]
|
|
|
|
likedComments CommentLike[]
|
2023-07-25 21:25:43 +00:00
|
|
|
followers Follows[] @relation("following")
|
|
|
|
following Follows[] @relation("follower")
|
|
|
|
postComments Comments[]
|
|
|
|
fromNotifications Notifications[] @relation("fromNotifications")
|
|
|
|
toNotifications Notifications[] @relation("toNotifications")
|
|
|
|
createdAt DateTime @default(now())
|
2023-06-20 20:05:15 +00:00
|
|
|
}
|
2023-06-23 18:15:11 +00:00
|
|
|
|
|
|
|
model Post {
|
|
|
|
id String @id @default(uuid())
|
|
|
|
content String
|
|
|
|
authorId String
|
2023-07-25 21:25:43 +00:00
|
|
|
author User @relation(fields: [authorId], references: [id], onDelete: Cascade)
|
2023-07-28 13:18:22 +00:00
|
|
|
likes PostLike[]
|
2023-07-25 21:25:43 +00:00
|
|
|
comments Comments[]
|
2023-06-23 18:15:11 +00:00
|
|
|
createdAt DateTime @default(now())
|
2023-06-27 23:24:26 +00:00
|
|
|
updatedAt DateTime @updatedAt
|
2023-07-25 13:57:23 +00:00
|
|
|
}
|
|
|
|
|
2023-07-28 13:18:22 +00:00
|
|
|
model PostLike {
|
2023-07-25 13:57:23 +00:00
|
|
|
id String @id @default(uuid())
|
|
|
|
postId String
|
2023-07-25 21:25:43 +00:00
|
|
|
post Post @relation(fields: [postId], references: [id], onDelete: Cascade)
|
2023-07-25 13:57:23 +00:00
|
|
|
userId String
|
2023-07-25 21:25:43 +00:00
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
2023-07-25 13:57:23 +00:00
|
|
|
createdAt DateTime @default(now())
|
|
|
|
}
|
2023-07-25 21:25:43 +00:00
|
|
|
|
2023-07-31 23:18:07 +00:00
|
|
|
// I should join these two up? Yeah, but I will not do it since it didn't work on the first time.
|
|
|
|
|
2023-07-28 13:18:22 +00:00
|
|
|
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())
|
|
|
|
}
|
|
|
|
|
2023-07-25 13:57:23 +00:00
|
|
|
model Follows {
|
2023-07-25 21:25:43 +00:00
|
|
|
follower User @relation("follower", fields: [followerId], references: [id], onDelete: Cascade)
|
2023-07-25 13:57:23 +00:00
|
|
|
followerId String
|
2023-07-25 21:25:43 +00:00
|
|
|
following User @relation("following", fields: [followingId], references: [id], onDelete: Cascade)
|
2023-07-25 13:57:23 +00:00
|
|
|
followingId String
|
|
|
|
|
|
|
|
@@id([followerId, followingId])
|
|
|
|
}
|
2023-07-25 21:25:43 +00:00
|
|
|
|
|
|
|
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)
|
2023-07-28 13:18:22 +00:00
|
|
|
likes CommentLike[]
|
2023-07-25 21:25:43 +00:00
|
|
|
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
|
2023-07-28 13:18:22 +00:00
|
|
|
INFO
|
2023-07-25 21:25:43 +00:00
|
|
|
}
|