Skip to content

Commit

Permalink
删除回复的数据库模型
Browse files Browse the repository at this point in the history
  • Loading branch information
wxh06 committed Jul 20, 2023
1 parent b1b34bc commit 50a0c59
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
14 changes: 14 additions & 0 deletions prisma/migrations/20230720105805_reply_takedown/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
-- CreateTable
CREATE TABLE "ReplyTakedown" (
"replyId" INTEGER NOT NULL,
"reason" TEXT NOT NULL,
"submitterId" INTEGER NOT NULL,

CONSTRAINT "ReplyTakedown_pkey" PRIMARY KEY ("replyId")
);

-- AddForeignKey
ALTER TABLE "ReplyTakedown" ADD CONSTRAINT "ReplyTakedown_replyId_fkey" FOREIGN KEY ("replyId") REFERENCES "Reply"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "ReplyTakedown" ADD CONSTRAINT "ReplyTakedown_submitterId_fkey" FOREIGN KEY ("submitterId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
20 changes: 15 additions & 5 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ model User {
pastes Paste[]
judgements Judgement[]
discussionTakedowns DiscussionTakedown[]
replyTakedowns ReplyTakedown[]
}

model Discussion {
Expand Down Expand Up @@ -49,13 +50,14 @@ model Snapshot {
}

model Reply {
id Int @id
discussion Discussion @relation(fields: [discussionId], references: [id])
id Int @id
discussion Discussion @relation(fields: [discussionId], references: [id])
discussionId Int
time DateTime @db.Timestamp(0)
author User @relation(fields: [authorId], references: [id])
time DateTime @db.Timestamp(0)
author User @relation(fields: [authorId], references: [id])
authorId Int
content String @db.Text
content String @db.Text
takedown ReplyTakedown?
@@index([discussionId])
}
Expand All @@ -68,6 +70,14 @@ model DiscussionTakedown {
submitterId Int
}

model ReplyTakedown {
reply Reply @relation(fields: [replyId], references: [id])
replyId Int @id
reason String
submitter User @relation(fields: [submitterId], references: [id])
submitterId Int
}

model Paste {
id String @id @db.Char(8)
time DateTime @db.Timestamp(0)
Expand Down

0 comments on commit 50a0c59

Please sign in to comment.