Skip to content

Commit 455d843

Browse files
junzero741claude
andcommitted
feat(backend): add Report model and migration
신고 기능을 위한 Report 모델과 ReportReason/ReportStatus enum 추가. Post 삭제 시 Report도 cascade 삭제. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 73dbb89 commit 455d843

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
-- CreateEnum
2+
CREATE TYPE "ReportReason" AS ENUM ('ILLEGAL_CONTENT', 'DEFAMATION', 'PERSONAL_INFO', 'PHISHING', 'COPYRIGHT', 'OTHER');
3+
4+
-- CreateEnum
5+
CREATE TYPE "ReportStatus" AS ENUM ('PENDING', 'DISMISSED');
6+
7+
-- CreateTable
8+
CREATE TABLE "Report" (
9+
"id" TEXT NOT NULL,
10+
"postId" TEXT NOT NULL,
11+
"reason" "ReportReason" NOT NULL,
12+
"description" TEXT,
13+
"reporterIp" TEXT NOT NULL,
14+
"status" "ReportStatus" NOT NULL DEFAULT 'PENDING',
15+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
16+
17+
CONSTRAINT "Report_pkey" PRIMARY KEY ("id")
18+
);
19+
20+
-- AddForeignKey
21+
ALTER TABLE "Report" ADD CONSTRAINT "Report_postId_fkey" FOREIGN KEY ("postId") REFERENCES "Post"("id") ON DELETE CASCADE ON UPDATE CASCADE;

apps/backend/prisma/schema.prisma

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,30 @@ model Post {
2222
expiresAt DateTime?
2323
createdAt DateTime @default(now())
2424
updatedAt DateTime @updatedAt
25+
reports Report[]
26+
}
27+
28+
model Report {
29+
id String @id @default(uuid())
30+
post Post @relation(fields: [postId], references: [id], onDelete: Cascade)
31+
postId String
32+
reason ReportReason
33+
description String?
34+
reporterIp String
35+
status ReportStatus @default(PENDING)
36+
createdAt DateTime @default(now())
37+
}
38+
39+
enum ReportReason {
40+
ILLEGAL_CONTENT
41+
DEFAMATION
42+
PERSONAL_INFO
43+
PHISHING
44+
COPYRIGHT
45+
OTHER
46+
}
47+
48+
enum ReportStatus {
49+
PENDING
50+
DISMISSED
2551
}

0 commit comments

Comments
 (0)