IT/Django
Django migrate sqlite to postgresql 마이그레이션
bepuri
2021. 11. 4. 14:53
728x90
마이그레이션 방법은 조금만 검색하면 많이 나온다.
먼저 python manage.py dumpdata -o data.json 실행
dumpdata Unable to serialize database: 'cp949' codec can't encode character '\ufeff' in position 232
윈도우에서 작업 진행시 로케일로 인한 위와 같은 오류를 만나는 경우
앞에 -Xutf8을 붙여주면 해결할 수 있다.python -Xutf8 manage.py dumpdata -o data.json
그 뒤 django 마이그레이션 파일로 백업한 DB로 복원을 시도할 서버에서 python manage.py migrate
를 진행해주고,
$python manage.py shell
실행후 쉘에서 아래 코드를 실행해준다.
from django.contrib.contenttypes.models import ContentType
ContentType.objects.all().delete()
그 뒤
python manage.py loaddata data.json
해주면 DB 복원이 완료된다.
728x90