codestates / codestates/Almost-There
[Error log] 외래키(foreign key) 설정이 되지 않는 문제 / 2022-02-24
- Dominant language
- TypeScript
- Stars
- 0
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
### 어떤 에러인가요?
Sequelize model에서 설정을 했으나, 서버를 켤 때 설정한 대로 테이블이 형성되지 않음.
### 에러 메시지

```bash
$ Referencing column 'sender' and referenced column 'userId' in foreign key constraint 'notifications_users_ibfk_1' are incompatible.'
```
### 에러 핸들링 방법
관계 설정하는 두 테이블 간의 character set이 달랐음. 관련 코드를 통일하니(삭제하기로 함) 해결됨.
```js
// Sequelize Model 설정에서 다음을 삭제:
charset: 'utf8',
collate: 'utf8_general_ci'
```
### 에러 핸들링을 위해 참고한 레퍼런스 링크
[Cannot add foreign key constraint](https://wooooooak.github.io/error/2018/09/03/cannotAddForeignKey/)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.