해당 방법은 migrate 초기화를 해도 안될때 사용하는 방법입니다.
해당 방법은 DB의 데이터를 날리기 때문에 💣
데이터를 날리면 안 된다면 아래의 방법을 사용하지마세요.
(venv) root@km-VirtualBox:~/django-with-react-study# python manage.py showmigrations blog1
blog1
[X] 0001_initial
[X] 0002_post_author
(venv) root@km-VirtualBox:~/django-with-react-study#
__init__.py
까지 돌아감.__init__.py
은 남아있어야됨.python manage.py migrate --fake <앱 이름> zero
(venv) root@km-VirtualBox:~/django-with-react-study# python manage.py migrate --fake blog1 zero
Operations to perform:
Unapply all migrations: blog1
Running migrations:
Rendering model states... DONE
Unapplying blog1.0002_post_author... FAKED
Unapplying blog1.0001_initial... FAKED
(venv) root@km-VirtualBox:~/django-with-react-study# python manage.py showmigrations blog1
blog1
[ ] 0001_initial
[ ] 0002_post_author
(venv) root@km-VirtualBox:~/django-with-react-study#
python manage.py migrate --fake <앱 이름> <마이그레이션 지점>
__init__.py
만 남기고 나머지 파일들을 다 지우기__init__.py
를 제외하고 다 삭제rm blog1/migrations/0001_initial.py
rm blog1/migrations/0002_post_author.py
(venv) root@km-VirtualBox:~/django-with-react-study# sqlite3 db.sqlite3
SQLite version 3.31.1 2020-01-27 19:55:54
Enter ".help" for usage hints.
sqlite> DROP TABLE blog1_post;
sqlite>
(venv) root@km-VirtualBox:~/django-with-react-study# python manage.py makemigrations blog1
Migrations for 'blog1':
blog1/migrations/0001_initial.py
- Create model Post
(venv) root@km-VirtualBox:~/django-with-react-study# python manage.py migrate blog1
Operations to perform:
Apply all migrations: blog1
Running migrations:
Applying blog1.0001_initial... OK
(venv)
[X] 0001_initial
(venv) root@km-VirtualBox:~/django-with-react-study# python manage.py showmigrations blog1
blog1
[X] 0001_initial
(venv) root@km-VirtualBox:~/django-with-react-study#
(venv) root@km-VirtualBox:~/django-with-react-study# sqlite3 db.sqlite3
SQLite version 3.31.1 2020-01-27 19:55:54
Enter ".help" for usage hints.
sqlite> .tables
accounts_profile django_admin_log
auth_group django_content_type
auth_group_permissions django_migrations
auth_permission django_session
auth_user instagram_comment
auth_user_groups instagram_post
auth_user_user_permissions instagram_post_tag_set
blog1_post instagram_tag
sqlite>
sqlite> SELECT * FROM blog1_post;
sqlite>