project-knedita/prisma/schema.prisma

106 lines
3.4 KiB
Text
Raw Permalink Normal View History

2023-06-20 20:05:15 +00:00
generator client {
provider = "prisma-kysely"
output = "../src/db"
fileName = "types.ts"
2023-06-20 20:05:15 +00:00
}
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
kweeks Kweek[]
profileImage String?
likedKweeks KweekLike[]
likedComments CommentLike[]
followers Follows[] @relation("follower")
following Follows[] @relation("following")
kweeksComments Comments[]
fromNotifications Notifications[] @relation("fromNotifications")
toNotifications Notifications[] @relation("toNotifications")
socketId String?
createdAt DateTime @default(now())
2023-06-20 20:05:15 +00:00
}
model Kweek {
id String @id @default(uuid())
content String
authorId String
author User @relation(fields: [authorId], references: [id], onDelete: Cascade)
likes KweekLike[]
comments Comments[]
attachments String[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model KweekLike {
kweekId String
kweek Kweek @relation(fields: [kweekId], references: [id], onDelete: Cascade)
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
createdAt DateTime @default(now())
@@id([kweekId, userId])
}
// I should join these two up? Yeah, but I will not do it since it didn't work on the first time.
model CommentLike {
commentId String
comment Comments @relation(fields: [commentId], references: [id], onDelete: Cascade)
2023-09-30 21:00:19 +00:00
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
createdAt DateTime @default(now())
@@id([commentId, userId])
}
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)
kweekId String?
kweek Kweek? @relation(fields: [kweekId], references: [id], onDelete: Cascade)
likes CommentLike[]
attachments String[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt @default(now())
parentId String?
parent Comments? @relation("CommentReplies", fields: [parentId], references: [id])
replies Comments[] @relation("CommentReplies")
}
model Notifications {
2023-09-30 21:00:19 +00:00
id String @id @default(uuid())
type NotificationType
content String
2023-09-30 21:00:19 +00:00
createdAt DateTime @default(now())
fromUserId String
2023-09-30 21:00:19 +00:00
fromUser User? @relation(name: "fromNotifications", fields: [fromUserId], references: [id], onDelete: Cascade)
toUserId String
2023-09-30 21:00:19 +00:00
toUser User? @relation(name: "toNotifications", fields: [toUserId], references: [id], onDelete: Cascade)
}
enum NotificationType {
WARNING
INFO
2024-02-03 14:41:32 +00:00
}