[211027] 업무일지

이승연·2021년 10월 27일
0

업무일지들

목록 보기
44/49

1. integrity error

데이터베이스 필드 중 null=True라고 분명히 명시했는데 자꾸 integrity error가 났다. [찾아보니] 모델이나 마이그레이션에 문제가 있는 것이 아니라 데이터베이스 자체의 캐싱 이슈 때문일 수 있다고 하더라. (https://stackoverflow.com/questions/16002090/django-model-field-has-null-true-but-yields-integrityerror-even-after-database-i)

you are doing everything fine. may be it was just a caching issue - with the pyc of the models still not having the updated nullable fields before doing the syncdb again. –
karthikr
Apr 14 '13 at 21:06

실제로 drf에서는 필수 필드는 값을 입력하라는 커스텀 메세지가 반환되는데 반환되지 않았다. 그리고 결정적으로 로컬에서는 잘 되는데 서버에서만 에러가 발생한다. migration 파일에 multiple leaf node가 있어서 초기화 후 다시 migration 했는데 이것 때문에 캐싱 업데이트에 시간이 걸린 것이 아닐까 싶다.

2. migrations 에러

Conflicting migrations detected [0001_migration_a, 0002_migration_b]. To fix them run python manage.py makemigrations --merge

이런 에러가 나는 경우가 있다. 다른 migration 파일이 의존하지 않는 migration 파일이 두개 이상 있으면 생기는 에러인데 아마 git pull을 해오면서 생긴 문제 같다. 분명히 .gitignore에 migration을 넣어놨는데도 이상하게도 가끔 migration 파일들이 다 따라온다. 왜일까. 어쨌든 이런 경우에는 모두 삭제하고 다시 migration 한다.

0개의 댓글