Skip to content

❗[버그][관리자][물품관리] 물품 삭제 시 trade_request_history FK 제약조건 위반으로 500 에러 발생 #627

@Cassiiopeia

Description

@Cassiiopeia

🗒️ 설명

  • Admin 페이지에서 물품(Item) 삭제 요청 시 500 에러가 발생한다
  • trade_request_history 테이블 삭제 시 chat_room 테이블에서 해당 trade_request_history_id를 참조하고 있어 FK 제약조건 위반이 발생한다
  • 에러 메시지: update or delete on table "trade_request_history" violates foreign key constraint "fknh0lbb6idicc0mr9r3dghm55y" on table "chat_room"

🔄 재현 방법

  1. Admin 페이지(/admin/items)에 로그인
  2. 물품 목록에서 특정 물품의 삭제 버튼 클릭
  3. POST /api/admin/items/delete API 호출됨
  4. 해당 물품에 연결된 거래 요청(trade_request_history)이 있고, 그 거래 요청을 참조하는 채팅방(chat_room)이 존재하면 500 에러 발생

📸 참고 자료

에러 로그:

could not execute statement [ERROR: update or delete on table "trade_request_history" violates foreign key constraint "fknh0lbb6idicc0mr9r3dghm55y" on table "chat_room"
  Detail: Key (trade_request_history_id)=(e604d1de-f6ca-4f5e-be93-b2d9bb14bfb2) is still referenced from table "chat_room".]

요청 정보:

  • 엔드포인트: POST /api/admin/items/delete
  • Content-Type: multipart/form-data
  • 요청 파라미터: itemId=faba1143-6b01-4d45-994b-6770a558d8e8

✅ 예상 동작

  • 물품 삭제 시 관련된 하위 엔티티(trade_request_history, chat_room 등)가 올바른 순서로 삭제되거나, 연관 데이터 처리 후 물품이 정상적으로 삭제되어야 한다

⚙️ 환경 정보

  • OS: Windows 10
  • 브라우저: Chrome 142

🙋‍♂️ 담당자

  • 백엔드: @Chuseok22
  • 프론트엔드: 이름
  • 디자인: 이름

Metadata

Metadata

Assignees

Labels

긴급긴급한 작업작업완료작업 완료 상태인 경우 (이슈 폐쇄)

Type

No type

Projects

Status

작업완료

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions