首页 > 其他 > 详细

django 重建一个表

时间:2021-08-19 14:51:58      阅读:14      评论:0      收藏:0      [点我收藏+]

 

有时候由于添加字段顺序不对,需要对table重建

1. 物理delete table

2.删除model上这个表

3. python manage.py makemigrations rowtable

 执行makemigration  - Delete model ParentSurvey

4.假装删除表,目的是让model与实际table一致

 python manage.py migrate --fake rowtable

5.在model上添加表,并makemigrations

(py3.6env) lxg@lxg-opt:~/98receive/pystudy/generaldb$ python manage.py makemigrations rowtable
Migrations for ‘rowtable‘:
rowtable/migrations/0010_parentsurvey.py
- Create model ParentSurvey

6.migrate ,物理上添加表
(py3.6env) lxg@lxg-opt:~/98receive/pystudy/generaldb$ python manage.py migrate rowtable

django 重建一个表

原文:https://www.cnblogs.com/lxgbky/p/15161171.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!