-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
accounts_app.models.py User 클래스의 whishlist = ....ManyToManyField(products_app.Product,..)와
products_app.models.py Product 클래스 충돌 문제
에러코드 :
django.db.utils.OperationalError: (1829, "Cannot drop column 'id': needed in a foreign key constraint '회원목록_whishlist_product_id_94e5a63e_fk_products_app_product_id' of table '회원목록_whishlist'")
원인 추론 :
Product 테이블의 id형식이 수정된 부분이 뒤늦게 반영되어 whishlist 테이블과 충돌함
해결방법 :
- accounts_app과 products_app의 migrations 폴더 삭제
- python manage.py makemigrations products_app
- python manage.py migrate products_app
- python manage.py makemigrations accounts_app
- python manage.py migrate accounts_app
proudcts_app에 존재하는 Product테이블을 먼저 생성시킨 후
accounts_app migration 진행
.
.
.
(GreatJung 추가 내용)
- 우선 mysql에서 django랑 연동 되어있는 database 전체를 삭제 (DROP 명령어)
- 모든 app 디렉의 migrations 폴더안 0001 과 같은 migraion 내용 삭제
- python manage.py makemigrations
- python manage.py migrate
이렇게만 해도 가능함
Metadata
Metadata
Assignees
Labels
No labels