에러 모음

[Django] InconsistentMigrationHistory 에러

개발자 지망생 리네 2025. 6. 3. 14:39

- 확인한 에러 코드

InconsistentMigrationHistory: Migration socialaccount.0001_initial is applied before its dependency sites.0001_initial

 

-> 연관되지 않은 마이그레이션 히스토리 : socialaccount 마이그레이션은 sites 앱에 의존

-> 그러나 sites가 적용되기 전에 socialaccount가 먼저 마이그레이션

-> 충돌

 

 

해결 방법

(1) django_migrations 테이블에서 socialaccount 관련 레코드 삭제

- mysql을 사용하는 관계로 아래 코드를 mysql에 접속해 입력한다.

mysql -u 사용자이름 -p
# 비밀번호 입력
USE schello;
DELETE FROM django_migrations WHERE app = 'socialaccount';

 

(2) .venv 터미널로 돌아가서 마이그레이션 순서대로 다시 실행

python manage.py migrate sites
python manage.py migrate socialaccount