Repository navigation
fix: 시드 밖 계정의 시드 상품 주문이 재시드를 막던 문제 수정 - #536
Conversation
- #535: 시드 밖 계정(로컬 구매자 테스트 계정 등)이 시드 매장 상품을 주문·리뷰하면 order_item·review의 product_id·store_id FK(RESTRICT) 때문에 재시드가 시드 상품 삭제에서 실패 - resetSeedScope 주문 정리 대상을 '시드 사용자 주문 + 시드 매장 품목이 든 주문'으로 넓힘. 주문은 상품 하나로 만들어져 매장도 하나라 시드 밖 매장 품목은 함께 지워지지 않음 - 이 주문·품목·리뷰를 가리키는 알림도 함께 삭제 — SET NULL로 대상 없는 알림이 남지 않게(#534 신고 건과 같은 축) - 회귀 테스트 2건(시드 상품 주문·리뷰 뒤 재시드, 시드 밖 매장 주문 보존). 반증: 수정 역적용 시 FK(product_id) 실패, 알림 정리만 빼면 알림 잔존으로 실패, 조회 조건을 전체로 넓히면 보존 테스트 실패
|
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: 80ae5a21c0
ℹ️ 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".
| where: { | ||
| OR: [ | ||
| { account_id: { in: userIds } }, | ||
| { items: { some: { store_id: { in: storeIds } } } }, |
There was a problem hiding this comment.
Run seed-store order cleanup without requiring seed users
When retrying after the original failure, this predicate is never reached because the entire order-cleanup block remains guarded by userIds.length > 0. The previous non-transactional reset deletes the seed users before reaching product deletion, where an outsider's order item causes the FK failure; consequently, the database state this fix must recover has seed stores and the blocking order but no seed users. A subsequent seed attempt still skips this query and fails at product deletion again, requiring manual cleanup instead of restoring idempotency. Move the seed-store order cleanup outside the user-only guard (while retaining user-specific cleanup separately).
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
반영: 주문 정리 블록을 userIds.length > 0 밖의 별도 블록(userIds.length > 0 || storeIds.length > 0)으로 이동. 시드 사용자 계정은 1) 끝에서 지워지고 실패는 2) 상품 삭제에서 나므로, 이미 한 번 실패한 DB(시드 사용자 없음 + 시드 매장·막는 주문 잔존)가 이번 수정으로도 복구되지 않던 경로가 맞음. 시드 매장만 있는 상태 재현 테스트 추가.
Coverage report
Test suite run success4299 tests passing in 387 suites. Report generated by 🧪jest coverage report action from cf0be14 |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
- 리뷰 #536 지적 반영: 주문 정리가 userIds.length > 0 블록 안에 있어, 이전 재시드가 2) 상품 삭제에서 실패한 DB(시드 사용자는 1) 끝에서 이미 삭제, 시드 매장·막는 주문 잔존)는 다시 돌려도 복구되지 않음 - 주문 정리를 사용자 조건과 분리(userIds 또는 storeIds가 있으면 실행), 나머지 유저 종속은 기존 조건 유지 - 회귀 테스트 1건(시드 매장만 남은 상태 재현). 반증: 사용자 조건을 되살리면 FK(product_id)로 실패, 적용 시 7건 통과
배경
yarn prisma:seed재실행이 시드 상품 삭제에서 실패합니다.order_item.product_id·order_item.store_id·review.product_id·review.store_idFK가 모두 RESTRICT입니다.resetSeedScope가 주문을 시드 사용자 기준으로만 지워, 시드 밖 계정의 주문 품목과 리뷰가 남았습니다.변경
createOrder의productId) 매장도 하나입니다. 그래서 시드 밖 매장의 품목이 함께 지워지지 않습니다.userIds.length > 0) 밖의 별도 블록으로 옮겼습니다(리뷰 지적 반영).테스트
src/test/seed-reset-scope.spec.ts에 실 DB 회귀 테스트 3건을 추가했습니다(총 7건).Foreign key constraint violated on the fields: (product_id)로 실패합니다.product_idFK 위반으로 실패합니다.플랜 대조
seed-reset-scope.spec.ts에 "시드 밖 계정이 시드 상품을 주문·리뷰한 뒤 재시드" 케이스 추가