南迁后1054未知列django [英] 1054 unknown column django after south migration
问题描述
已将我的应用程序和数据库与南方同步.
Have sync my app and db with south.
数据库很旧,我想添加一些新列.
The database is old and I want to add some new columns.
1: python manage.py convert_to_south myappName
2: python manage.py schemamigration myappName --auto
3: python manage.py migrate myappName --fake (did use for a table, but not the
table that is the problem)
4: python manage.py migrate myappName
一切看起来都很不错,应用已同步了所有内容.
Everything looks nice, app is synced an everything.
但是我仍然得到1054 ....
But i still get 1054....
有什么想法吗?
推荐答案
这是因为您在向模型中添加了列之后,但实际上没有出现在数据库中之前创建了初始迁移.
Its because you create a initial migration after you added a column to your model, but before its actually appears in the database.
正确的工作流程应如下:
The correct workflow should be following:
1)拥有一个运行中的Django应用,该应用不会抛出任何未知的列.(将新列注释掉)
1) Have a working django app that don't throw any unknown column. ( comment out the new columns)
2)执行步骤1-4
2) Do your step 1-4
3)然后,您需要添加所需的列并再次运行第2步(schemamigration myappName --auto).
3) Then you need to add the columns you want and run your step 2 ( schemamigration myappName --auto) once more.
4)然后,您需要运行migrate命令.
4) Then you need to run migrate command.
就这样
这篇关于南迁后1054未知列django的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!