程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Django - migrate reset

編輯:Python

Use django In the process , Found missing migrate The problem of , When updating the database , need migrate Error reporting solution

  • Delete database , rebuild library
  • Reset migtate

Here under migrate Reset problem

1. View local migrate history

python3 manage.py showmigrations
action_backend
[X] 0001_initial
[X] 0002_auto_20180228_0136
[X] 0003_magnetdata_reading_time
[X] 0004_auto_20180302_0650
[X] 0005_auto_20180510_0812
admin
[X] 0001_initial
[X] 0002_logentry_remove_auto_add
auth
[X] 0001_initial
[X] 0002_alter_permission_name_max_length
[X] 0003_alter_user_email_max_length
[X] 0004_alter_user_username_opts
[X] 0005_alter_user_last_login_null
[X] 0006_require_contenttypes_0002
[X] 0007_alter_validators_add_error_messages

2. Reset

python3 manage.py migrate --fake action_backend zero
// see 
python3 manage.py showmigrations
action_backend
[ ] 0001_initial
[ ] 0002_auto_20180228_0136
[ ] 0003_magnetdata_reading_time
[ ] 0004_auto_20180302_0650
[ ] 0005_auto_20180510_0812
admin
[X] 0001_initial
[X] 0002_logentry_remove_auto_add
auth
[X] 0001_initial
[X] 0002_alter_permission_name_max_length
[X] 0003_alter_user_email_max_length
[X] 0004_alter_user_username_opts
[X] 0005_alter_user_last_login_null
[X] 0006_require_contenttypes_0002
[X] 0007_alter_validators_add_error_messages

3.makemigrations

Delete , migrate Files in the folder ,

python3 manage.py makemigrations
No changes detected

4.initial

To regenerate the 0001_initial.py

python3 manage.py migrate --fake-initial

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved