카드 생성 api 구현 중
더보기
Cannot add or update a child row: a foreign key constraint fails (`database_workFlow_project`.`cards`, CONSTRAINT `FK_0813e876c2b327e7c4ae7cc4793` FOREIGN KEY (`board_column_id`) REFERENCES `board_columns` (`id`) ON DELETE CASCADE)
이런 오류 발생
//카드 생성
async CreateCard(
board_column_id: number,
name: string,
content: string,
file_url: string,
sequence: number,
color: string,
members: number[]
) {
const column = await this.boardColumnService.findOneBoardColumnById(board_column_id);
if (!column) {
throw new NotFoundException('컬럼을 찾을 수 없습니다.');
}
await this.cardRepository.insert({ board_colum_Id, name, content, file_url, sequence, color, members });
}
이 코드에서 board_colum_Id로 불러오는데 엔티티 에선 board_column 으로 내보내줘서 생긴 문제로 파악
//카드 생성
async CreateCard(
board_column_id: number,
name: string,
content: string,
file_url: string,
sequence: number,
color: string,
members: number[]
) {
const column = await this.boardColumnService.findOneBoardColumnById(board_column_id);
if (!column) {
throw new NotFoundException('컬럼을 찾을 수 없습니다.');
}
await this.cardRepository.insert({ board_column: column, name, content, file_url, sequence, color, members });
}
이런 식으로 board_column 으로 가져와서 column 에 id를 내보내 도록 수정