Add Comment model for issue comments
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2696f33a7e
commit
3272c75512
2 files changed
+46
No files matched your search
@@ -0,0 +1,25 @@
|
|||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "comment" (
|
||||||
|
"id" TEXT NOT NULL,
|
||||||
|
"content" TEXT NOT NULL,
|
||||||
|
"issueId" INTEGER NOT NULL,
|
||||||
|
"authorId" TEXT,
|
||||||
|
"editedAt" TIMESTAMPTZ(3),
|
||||||
|
"deletedAt" TIMESTAMPTZ(3),
|
||||||
|
"createdAt" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updatedAt" TIMESTAMPTZ(3) NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "comment_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE INDEX "comment_issueId_createdAt_idx" ON "comment"("issueId", "createdAt");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE INDEX "comment_authorId_idx" ON "comment"("authorId");
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "comment" ADD CONSTRAINT "comment_issueId_fkey" FOREIGN KEY ("issueId") REFERENCES "issue"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "comment" ADD CONSTRAINT "comment_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "user"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||||
@@ -24,6 +24,7 @@ model User {
|
|||||||
notificationDeviceTokens NotificationDeviceToken[]
|
notificationDeviceTokens NotificationDeviceToken[]
|
||||||
notificationPreferences NotificationPreference[]
|
notificationPreferences NotificationPreference[]
|
||||||
notificationMessages NotificationMessage[]
|
notificationMessages NotificationMessage[]
|
||||||
|
comments Comment[]
|
||||||
|
|
||||||
@@unique([email])
|
@@unique([email])
|
||||||
@@map("user")
|
@@map("user")
|
||||||
@@ -92,6 +93,7 @@ model Issue {
|
|||||||
projectId String
|
projectId String
|
||||||
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
||||||
dueDate DateTime? @db.Timestamptz(3)
|
dueDate DateTime? @db.Timestamptz(3)
|
||||||
|
comments Comment[]
|
||||||
createdAt DateTime @default(now()) @db.Timestamptz(3)
|
createdAt DateTime @default(now()) @db.Timestamptz(3)
|
||||||
updatedAt DateTime @updatedAt @db.Timestamptz(3)
|
updatedAt DateTime @updatedAt @db.Timestamptz(3)
|
||||||
|
|
||||||
@@ -188,3 +190,22 @@ model NotificationMessage {
|
|||||||
@@index([createdAt])
|
@@index([createdAt])
|
||||||
@@map("notification_message")
|
@@map("notification_message")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Комментарий к задаче. При удалении автора комментарий остаётся (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)
|
||||||
|
|
||||||
|
@@index([issueId, createdAt])
|
||||||
|
@@index([authorId])
|
||||||
|
@@map("comment")
|
||||||
|
}
|
||||||
Reference in new issue
Block a user