Skip to content

chore: 릴리즈 — 시드 재실행 FK 실패 수정(리뷰 댓글·시드 밖 주문) - #537

Merged
chanwoo7 merged 6 commits into
mainfrom
develop
Oct 15, 2026
Merged

chanwoo7 merged 6 commits into
mainfrom
develop

Conversation

@chanwoo7

@chanwoo7 chanwoo7 commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

로컬 개발 DB에서 yarn prisma:seed 재실행이 FK로 실패하던 문제를 고친 시드 스크립트 수정을 반영합니다. FE 로컬 개발 가이드(관리자·판매자)를 검증하다 발견했습니다.

운영 반영 사항입니다.

  • 바뀐 것은 prisma/seed/와 테스트뿐입니다. 시드는 NODE_ENV=production에서 차단되므로 운영 동작은 바뀌지 않습니다.
  • 마이그레이션·SDL·시크릿 변경은 없습니다.

Summary by CodeRabbit

  • 버그 수정

    • 시드 매장 상품이 포함된 주문과 관련 리뷰·알림까지 정리하도록 개선했습니다.
    • 리뷰를 삭제하기 전에 연결된 댓글과 댓글 신고도 함께 정리합니다.
    • 시드 계정의 주문 및 댓글은 관련 데이터와 함께 정리되며, 외부 계정과 외부 매장 주문은 유지됩니다.
  • 테스트

    • 다양한 주문·리뷰·댓글 관계에서 정리 결과와 외부 데이터 보존을 확인하는 통합 테스트를 추가했습니다.

- 증상: 로컬에서 시드 리뷰에 댓글이 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건 통과
- 리뷰 #534 지적 반영: 시드 리뷰의 댓글을 지우면 그 댓글 신고가 SET NULL로 대상 없는 PENDING이 됨. 신고 목록은 targetedReportWhere로 숨기지만 대시보드 대기 신고 수(countPendingReviewReports)는 계속 셈
- 0) 신고 정리에 시드 리뷰(시드 사용자 작성·시드 매장) 댓글 대상 신고 조건 추가
- 회귀 테스트 1건(외부 댓글의 외부 신고). 반증: 수정 역적용 시 이 1건 실패, 적용 시 4건 통과
fix: 시드 재실행이 리뷰 댓글 FK로 실패하던 문제 수정
- #535: 시드 밖 계정(로컬 구매자 테스트 계정 등)이 시드 매장 상품을 주문·리뷰하면 order_item·review의 product_id·store_id FK(RESTRICT) 때문에 재시드가 시드 상품 삭제에서 실패
- resetSeedScope 주문 정리 대상을 '시드 사용자 주문 + 시드 매장 품목이 든 주문'으로 넓힘. 주문은 상품 하나로 만들어져 매장도 하나라 시드 밖 매장 품목은 함께 지워지지 않음
- 이 주문·품목·리뷰를 가리키는 알림도 함께 삭제 — SET NULL로 대상 없는 알림이 남지 않게(#534 신고 건과 같은 축)
- 회귀 테스트 2건(시드 상품 주문·리뷰 뒤 재시드, 시드 밖 매장 주문 보존). 반증: 수정 역적용 시 FK(product_id) 실패, 알림 정리만 빼면 알림 잔존으로 실패, 조회 조건을 전체로 넓히면 보존 테스트 실패
- 리뷰 #536 지적 반영: 주문 정리가 userIds.length > 0 블록 안에 있어, 이전 재시드가 2) 상품 삭제에서 실패한 DB(시드 사용자는 1) 끝에서 이미 삭제, 시드 매장·막는 주문 잔존)는 다시 돌려도 복구되지 않음
- 주문 정리를 사용자 조건과 분리(userIds 또는 storeIds가 있으면 실행), 나머지 유저 종속은 기존 조건 유지
- 회귀 테스트 1건(시드 매장만 남은 상태 재현). 반증: 사용자 조건을 되살리면 FK(product_id)로 실패, 적용 시 7건 통과
fix: 시드 밖 계정의 시드 상품 주문이 재시드를 막던 문제 수정
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-15T12:52:14.150664Z 430c181 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: CaQuick/caquick-be/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0bdf631e-d1b9-4bad-9721-7df982b05f5a
📥 Commits

Reviewing files that changed from the base of the PR and between 4afb407 and 430c181.

📒 Files selected for processing: 2
  • prisma/seed/idempotent.ts
  • src/test/seed-reset-scope.spec.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

resetSeedScope가 시드 매장 상품이 포함된 주문과 이에 연결된 알림·리뷰·댓글·신고를 정리합니다. 실제 DB 통합 테스트는 정리 대상과 보존 대상을 검증합니다.

Changes: 시드 범위 초기화

Layer / File(s) Summary
주문 및 리뷰 종속 데이터 정리
prisma/seed/idempotent.ts
초기화 대상 주문에 시드 매장 상품이 포함된 주문을 추가합니다. 주문·품목·리뷰를 참조하는 알림과 리뷰에 연결된 댓글·신고를 정리합니다. 시드 계정이 작성한 댓글과 시드 계정 리뷰의 댓글도 삭제합니다.
실제 DB 초기화 테스트
src/test/seed-reset-scope.spec.ts
시드 범위 주문·리뷰·댓글·신고의 삭제와 외부 계정·외부 매장 주문의 보존을 확인합니다. 일부 시나리오에서는 초기화 후 재시드를 수행합니다.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 430c1

The seed reset and its database tests have no established issue requiring a fix before merge. Normal checks still apply.

Pre-merge checks: Passed 3 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed PR 제목은 시드 재실행 중 발생한 FK 실패 수정이라는 주요 변경을 설명합니다. 리뷰 댓글과 시드 밖 주문 정리도 변경 내용과 일치합니다.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

🧹 knip — dead-code 리포트

Unused exported types (1)
전체 리포트
Unused exported types (1)
RateLimitPolicy  type  src/global/rate-limit/index.ts:4:8

청소 후보(오탐 가능) · 기준 docs/guide/architecture-conventions.md

@github-actions

Copy link
Copy Markdown

🩺 NestJS Doctor — 90/100 (Excellent)

진단 486건 (error 12).

Category error warning info
architecture 1 1 44
correctness 0 268 0
performance 0 36 28
schema 0 0 76
security 11 21 0
architecture / security 상위 항목
  • error architecture/architecture/no-manual-instantiation: Manual instantiation of 'OutboxRepository' detected. Use dependency injection instead.
  • info architecture/architecture/no-barrel-export-internals: Barrel file re-exports internal type 'IAuditLogRepository'.
  • warning security/security/no-exposed-env-vars: Direct 'process.env.NODE_ENV' access in 'AuthController'. Use ConfigService instead.
  • warning security/security/require-guards-on-endpoints: Endpoint 'start' has no @UseGuards() at class or method level.
  • warning security/security/require-guards-on-endpoints: Endpoint 'callback' has no @UseGuards() at class or method level.
  • warning security/security/require-guards-on-endpoints: Endpoint 'refresh' has no @UseGuards() at class or method level.
  • warning security/security/require-guards-on-endpoints: Endpoint 'logout' has no @UseGuards() at class or method level.
  • warning security/security/require-guards-on-endpoints: Endpoint 'sellerLogin' has no @UseGuards() at class or method level.
  • warning security/security/require-guards-on-endpoints: Endpoint 'sellerRefresh' has no @UseGuards() at class or method level.
  • warning security/security/require-guards-on-endpoints: Endpoint 'sellerLogout' has no @UseGuards() at class or method level.
  • warning security/security/require-guards-on-endpoints: Endpoint 'devIssueToken' has no @UseGuards() at class or method level.
  • warning security/security/require-guards-on-endpoints: Endpoint 'adminLogin' has no @UseGuards() at class or method level.
  • warning security/security/require-guards-on-endpoints: Endpoint 'adminRefresh' has no @UseGuards() at class or method level.
  • warning security/security/require-guards-on-endpoints: Endpoint 'adminLogout' has no @UseGuards() at class or method level.
  • warning security/security/require-guards-on-endpoints: Endpoint 'getJwks' has no @UseGuards() at class or method level.

오탐 포함 가능 · 기준 docs/guide/architecture-conventions.md

@github-actions

Copy link
Copy Markdown

Coverage report

St.❔
Category Percentage Covered / Total
🟢 Statements 98.02% 10791/11009
🟢 Branches 92.95% 4112/4424
🟢 Functions 97.55% 2150/2204
🟢 Lines 98.59% 9818/9958

Test suite run success

4299 tests passing in 387 suites.

Report generated by 🧪jest coverage report action from 430c181

@codecov

codecov Bot commented Oct 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@chanwoo7
chanwoo7 merged commit 257edb3 into main Oct 15, 2026
27 checks passed
@chanwoo7
chanwoo7 deleted the develop branch October 15, 2026 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant