본문 바로가기
Django

[django]"django_content_type" already exists 에러 발생시

by SAMSUNG CLOUD-OKY 2021. 4. 5.
반응형

python manage.py migrate 뒤에 --fake-initial 옵션을 붙여주면 된다. 

-> python manage.py migrate --fake-initial

 

--fake-initial이란?

The --fake-initial option can be used to allow Django to skip an app’s initial migration if all database tables with the names of all models created by all CreateModel operations in that migration already exist. This option is intended for use when first running migrations against a database that preexisted the use of migrations. This option does not, however, check for matching database schema beyond matching table names and so is only safe to use if you are confident that your existing schema matches what is recorded in your initial migration.

 

DB가 이미 생성되어있으면(테이블명 등 일치) migration을 하지 않는다.

 

 

 

 

 

--fake-initial이란?

--fake-initial 옵션을 사용하면 해당 마이그레이션의 모든 CreateModel 작업에 의해 생성 된 모든 모델의 이름을 가진 모든 데이터베이스 테이블이 이미 존재하는 경우 Django가 앱의 초기 마이그레이션을 건너 뛸 수 있습니다.

이 옵션은 마이그레이션 사용이 이미 존재했던 데이터베이스에 대해 마이그레이션을 처음 실행할 때 사용하기위한 것입니다.

그러나이 옵션은 일치하는 테이블 이름 외에 일치하는 데이터베이스 스키마를 확인하지 않으므로 기존 스키마가 초기 마이그레이션에 기록 된 것과 일치한다고 확신하는 경우에만 사용하는 것이 안전합니다.

 

 

 

 

 

 

 

 

 

 

 

 

반응형

댓글