Skip to content

[Fix] - 공개 코스 삭제 시 FK 제약 위반 수정#170

Merged
thingineeer merged 1 commit intodevfrom
feat/#168-admin-delete
Feb 19, 2026
Merged

[Fix] - 공개 코스 삭제 시 FK 제약 위반 수정#170
thingineeer merged 1 commit intodevfrom
feat/#168-admin-delete

Conversation

@thingineeer
Copy link
Contributor

@thingineeer thingineeer commented Feb 19, 2026

😶 무슨 이슈인가요?


관리자가 타인의 공개 코스를 삭제할 때 500 Internal Server Error 발생.
deleteAllInBatch가 JPA cascade를 무시하고 직접 SQL DELETE를 실행하여, Scrap 테이블의 FK 제약 조건 위반.

🤔 어떻게 이슈를 해결했나요?


  • publicCourseRepository.deleteAllInBatch() 호출 전에 scrapRepository.deleteByPublicCourseIn(publicCourses) 추가
  • 이미 ScrapRepository에 정의되어 있던 메서드를 활용 (신규 코드 없음)
  • 삭제 순서: 스크랩 삭제 → isPrivate 업데이트 → 공개 코스 삭제

🤯 주의할 점이 있나요?


  • 이 버그는 관리자뿐 아니라, 스크랩된 코스를 소유자가 삭제할 때도 동일하게 발생할 수 있었던 잠재적 버그인 것 같네용
  • deleteAllInBatch는 JPA lifecycle callback과 cascade를 무시하므로 연관 엔티티를 수동으로 먼저 삭제해야 합니다!

- deleteAllInBatch가 FK cascade를 무시하여 Scrap FK 제약 위반으로 500 에러 발생
- 공개 코스 삭제 전 scrapRepository.deleteByPublicCourseIn() 호출 추가
@thingineeer thingineeer self-assigned this Feb 19, 2026
@thingineeer thingineeer merged commit 8c4fac6 into dev Feb 19, 2026
1 of 2 checks passed
@thingineeer thingineeer deleted the feat/#168-admin-delete branch February 19, 2026 12:33
thingineeer added a commit that referenced this pull request Feb 19, 2026
[Fix] - 공개 코스 삭제 시 Record FK null 처리 추가
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments