마이그레이션 실행여부 확인하기
장고 마이그레이션을 실행하고 나서 의도한대로 마이그레이션이 되었는지 확인하려면 아래 명령어를 실행한다. (버전 1.8 이상부터 가능)
$ python manage.py showmigrations --list
--list
옵션은 각 앱들의 마이그레이션 파일 목록을 보여주는데, DB에 제대로 반영된 마이그레이션은 [X]
으로, 아직 반영되지 않은 마이그레이션은 [ ]
으로 표기한다.
$ python manage.py showmigrations --list
admin
[X] 0001_initial
[X] 0002_logentry_remove_auto_add
student
[X] 0001_initial
[X] 0002_create_initial_student_key
[X] 0003_add_help_text
[ ] 0004_add_unique_constraint_to_student
특정 앱의 마이그레이션 목록만 보고싶다면 아래와 같이 앱 라벨을 추가한다.
$ python manage.py showmigrations student --list
반영되지 않은 마이그레이션 목록만 보고싶다면 grep
으로 필터링하면 된다.
$ python manage.py showmigrations --list | grep '\[ \]'
[ ] 0004_add_unique_constraint_to_student
출처
Last updated
Was this helpful?