Skip to content

[FIX] 테스트 사용자 삭제 시 외래키 제약 위반 오류 발생 #471

@Baguette-bbang

Description

@Baguette-bbang

⚠️ Issue

사용자 삭제 시 user_block 테이블의 blocked_user_id 외래키 제약 조건에 의해 삭제가 차단되는 문제가 발생했다. 현재 user_block.blocked_user_id가 user.id를 참조하고 있어, 해당 사용자가 차단된 이력이 있을 경우 직접 삭제가 불가능하다.

에러 로그

SQL Error: 1451, SQLState: 23000
Cannot delete or update a parent row: a foreign key constraint fails (`desserbee_release`.`user_block`, CONSTRAINT `FKlvu9vu217et5ntykj35bp9ubu` FOREIGN KEY (`blocked_user_id`) REFERENCES `user` (`id`))

재현방법

A 유저가 [email protected] 유저를 차단
[email protected] 유저가 자신의 계정을 삭제 시도
DataIntegrityViolationException 발생

테스트 계정([email protected])은 Hard Delete 처리
일반 사용자는 Soft Delete 처리로 문제 없음
Hard Delete 시 user_block 테이블의 외래키 참조로 인해 삭제 실패

✏️ ToDoList

  • UserTestController 생성 (user/controller/)
  • UserTestService 생성 (user/service/)
  • 릴리즈 환경에서만 활성화되는 테스트 API 구현
  • 관련 데이터 cascade 삭제 기능 구현

Metadata

Metadata

Labels

🐛 bugSomething isn't working✨ featureNew feature or requestdocumentationImprovements or additions to documentation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions