Api+App: komentarze usera - statusy przeczytania i typ USER_COMMENT (feed, profil, panel trenera)
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
-- AlterEnum
|
||||
ALTER TYPE "NotificationType" ADD VALUE 'USER_COMMENT';
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "CommentRead" (
|
||||
"commentId" TEXT NOT NULL,
|
||||
"userId" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "CommentRead_pkey" PRIMARY KEY ("commentId","userId")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "CommentRead_userId_idx" ON "CommentRead"("userId");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "CommentRead" ADD CONSTRAINT "CommentRead_commentId_fkey" FOREIGN KEY ("commentId") REFERENCES "Comment"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "CommentRead" ADD CONSTRAINT "CommentRead_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -157,6 +157,7 @@ model User {
|
||||
coachingsAsUser Coaching[] @relation("CoachingUser")
|
||||
commentsAsAuthor Comment[] @relation("CommentAuthor")
|
||||
commentsAsTarget Comment[] @relation("CommentTarget")
|
||||
commentReads CommentRead[]
|
||||
messagesAsSender Message[] @relation("MessageSender")
|
||||
conversationReads ConversationRead[]
|
||||
activityLogs ActivityLog[] @relation("ActivityLogActor")
|
||||
@@ -230,10 +231,25 @@ model Comment {
|
||||
author User @relation("CommentAuthor", fields: [authorId], references: [id], onDelete: Cascade)
|
||||
target User @relation("CommentTarget", fields: [targetUserId], references: [id], onDelete: Cascade)
|
||||
sessionExercise SessionExercise? @relation(fields: [sessionExerciseId], references: [id], onDelete: SetNull)
|
||||
reads CommentRead[]
|
||||
|
||||
@@index([targetUserId, createdAt])
|
||||
}
|
||||
|
||||
/// Oznaczenie przeczytania komentarza per widz (wzór ConversationRead) — do
|
||||
/// licznika nieprzeczytanych w historii. Autor nigdy nie potrzebuje wiersza.
|
||||
model CommentRead {
|
||||
commentId String
|
||||
userId String
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
comment Comment @relation(fields: [commentId], references: [id], onDelete: Cascade)
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@id([commentId, userId])
|
||||
@@index([userId])
|
||||
}
|
||||
|
||||
/// Wiadomość w wątku trener↔podopieczny (per Coaching).
|
||||
model Message {
|
||||
id String @id @default(cuid())
|
||||
@@ -270,6 +286,7 @@ enum NotificationType {
|
||||
PLAN_SHARED
|
||||
GYM_DELETED
|
||||
TRAINER_COMMENT
|
||||
USER_COMMENT
|
||||
}
|
||||
|
||||
/// Osobiste powiadomienie generowane przez system. `payload` jest self-contained
|
||||
|
||||
Reference in New Issue
Block a user