Repository navigation
fix: 시드 재실행이 리뷰 댓글 FK로 실패하던 문제 수정 - #534
Conversation
- 증상: 로컬에서 시드 리뷰에 댓글이 1건이라도 있으면 yarn prisma:seed 재실행이 resetSeedScope의 review.deleteMany에서 FK 위반으로 실패. 시드 사용자가 시드 밖 리뷰에 댓글을 달아도 계정 삭제가 막힘 - 원인: review_comment의 review_id·account_id FK가 둘 다 RESTRICT인데 resetSeedScope 정리 대상에 review_comment가 없음(review_report의 댓글 FK는 SET NULL이라 해당 없음) - 변경: 주문 아이템 기준 리뷰 삭제 앞에 그 리뷰의 댓글 삭제, 사용자 기준 리뷰 삭제 앞에 시드 사용자가 쓴 댓글과 시드 사용자 리뷰의 댓글 삭제 - 회귀 테스트 3건(src/test/seed-reset-scope.spec.ts, 실 시드 함수로 리뷰까지 채운 뒤 정리): 시드 리뷰에 외부 계정 댓글 → 정리 후 재시드 / 시드 사용자가 외부 리뷰에 단 댓글 → 댓글만 삭제·리뷰 유지 / 시드 주문 밖 시드 사용자 리뷰의 댓글 삭제 - 반증: 수정 역적용 시 3건 모두 FK 위반(review_id·account_id·review_id)으로 실패, 재적용 시 3건 통과
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
🧹 knip — dead-code 리포트전체 리포트
|
🩺 NestJS Doctor — 90/100 (Excellent)진단 486건 (error 12).
architecture / security 상위 항목
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6ad44459ab
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| await prisma.reviewComment.deleteMany({ | ||
| where: { review: { order_item_id: { in: orderItemIds } } }, | ||
| }); |
There was a problem hiding this comment.
Settle comment reports before deleting seeded-review comments
When an external user reports an external user's comment on a seeded review, the earlier reviewReport.deleteMany does not match it because comment reports have no review_id and the comment author is not seeded. This hard delete therefore only applies the FK's ON DELETE SET NULL, leaving a PENDING report with both target IDs null and its open_key intact; ReviewAdminRepository.targetedReportWhere then excludes it from listing, detail, and resolution forever. Delete or resolve reports selected through review_comment.review before deleting these comments; the second newly added comment-deletion path has the same issue.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
반영: 0) 신고 정리 단계에 "시드 리뷰(시드 사용자 작성·시드 매장)에 달린 댓글을 대상으로 한 신고" 조건 추가 — 댓글 삭제 전에 지워 대상 없는 PENDING이 남지 않음. 대시보드 대기 신고 수(countPendingReviewReports)가 대상 없는 PENDING까지 세므로 실제 불일치. 시드 사용자가 남의 리뷰에 단 댓글의 신고는 기존 review_comment.account_id 조건이 이미 덮음. 회귀 테스트 1건 추가.
Coverage report
Test suite run success4296 tests passing in 387 suites. Report generated by 🧪jest coverage report action from f83757c |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
- 리뷰 #534 지적 반영: 시드 리뷰의 댓글을 지우면 그 댓글 신고가 SET NULL로 대상 없는 PENDING이 됨. 신고 목록은 targetedReportWhere로 숨기지만 대시보드 대기 신고 수(countPendingReviewReports)는 계속 셈 - 0) 신고 정리에 시드 리뷰(시드 사용자 작성·시드 매장) 댓글 대상 신고 조건 추가 - 회귀 테스트 1건(외부 댓글의 외부 신고). 반증: 수정 역적용 시 이 1건 실패, 적용 시 4건 통과
배경
yarn prisma:seed재실행이 실패합니다.resetSeedScope의prisma.review.deleteMany()(Foreign key constraint violated onreview_id)account_idFK에 막힙니다.review_comment의review_id·account_idFK가 둘 다 RESTRICT인데,resetSeedScope의 정리 대상에review_comment가 빠져 있던 것입니다.review_report.review_comment_id는 SET NULL이라 함께 정리할 필요가 없습니다.변경
prisma/seed/idempotent.ts에 댓글 정리를 두 곳 추가했습니다.테스트
src/test/seed-reset-scope.spec.ts에 실 DB 회귀 테스트 4건을 추가했습니다. 실제 시드 함수로 리뷰까지 채운 뒤 정리합니다.review_id·account_id·review_id)으로 실패합니다.prisma/)와src/test/는 커버리지 수집 대상이 아니라 임계에는 영향이 없습니다.플랜 대조
resetSeedScope에review_comment정리 추가(리뷰 FK·계정 FK 양쪽)