Add attachments to comments
- CommentAttachment link table (comment <-> file) + migration - fileIds in create/update comment; update replaces the whole set, synced in one transaction with the comment - CommentDto.attachments; empty for deleted comments - Soft delete drops attachments so GC can collect the files - Max 10 files per comment, ordered by upload time (uuid v7) - Registers comments as a file owner - Rename CommentAuthorExpanderService -> CommentExpanderService (expands authors and files) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
423afa658d
commit
60fb39f98f
28 files changed
+522
-69
No files matched your search
+28
-11
@@ -196,16 +196,17 @@ model NotificationMessage {
|
||||
/// Комментарий к задаче. При удалении автора комментарий остаётся (authorId -> NULL).
|
||||
/// deletedAt — мягкое удаление, editedAt — время последней правки текста.
|
||||
model Comment {
|
||||
id String @id @default(uuid(7))
|
||||
content String
|
||||
issueId Int
|
||||
issue Issue @relation(fields: [issueId], references: [id], onDelete: Cascade)
|
||||
authorId String?
|
||||
author User? @relation(fields: [authorId], references: [id], onDelete: SetNull)
|
||||
editedAt DateTime? @db.Timestamptz(3)
|
||||
deletedAt DateTime? @db.Timestamptz(3)
|
||||
createdAt DateTime @default(now()) @db.Timestamptz(3)
|
||||
updatedAt DateTime @updatedAt @db.Timestamptz(3)
|
||||
id String @id @default(uuid(7))
|
||||
content String
|
||||
issueId Int
|
||||
issue Issue @relation(fields: [issueId], references: [id], onDelete: Cascade)
|
||||
authorId String?
|
||||
author User? @relation(fields: [authorId], references: [id], onDelete: SetNull)
|
||||
editedAt DateTime? @db.Timestamptz(3)
|
||||
deletedAt DateTime? @db.Timestamptz(3)
|
||||
createdAt DateTime @default(now()) @db.Timestamptz(3)
|
||||
updatedAt DateTime @updatedAt @db.Timestamptz(3)
|
||||
attachments CommentAttachment[]
|
||||
|
||||
@@index([issueId, createdAt])
|
||||
@@index([authorId])
|
||||
@@ -226,7 +227,8 @@ model File {
|
||||
uploader User? @relation(fields: [uploaderId], references: [id], onDelete: SetNull)
|
||||
createdAt DateTime @default(now()) @db.Timestamptz(3)
|
||||
|
||||
issueAttachments IssueAttachment[]
|
||||
issueAttachments IssueAttachment[]
|
||||
commentAttachments CommentAttachment[]
|
||||
|
||||
@@unique([storageKey])
|
||||
@@index([uploaderId])
|
||||
@@ -247,3 +249,18 @@ model IssueAttachment {
|
||||
@@index([fileId])
|
||||
@@map("issue_attachment")
|
||||
}
|
||||
|
||||
/// Вложение комментария — связь комментария с файлом. Управляется вместе
|
||||
/// с комментарием (fileIds в create/update); при мягком удалении комментария
|
||||
/// связи снимаются, чтобы файлы забрал GC.
|
||||
model CommentAttachment {
|
||||
commentId String
|
||||
comment Comment @relation(fields: [commentId], references: [id], onDelete: Cascade)
|
||||
fileId String
|
||||
file File @relation(fields: [fileId], references: [id], onDelete: Cascade)
|
||||
createdAt DateTime @default(now()) @db.Timestamptz(3)
|
||||
|
||||
@@id([commentId, fileId])
|
||||
@@index([fileId])
|
||||
@@map("comment_attachment")
|
||||
}
|
||||
Reference in new issue
Block a user