我启动了一个使用迁移系统的Django 1.8项目.
不知怎么的,事情变得乱七八糟,所以我从数据库中删除了迁移文件夹和表,现在我试图重建它们,但没有成功.
我有三个应用程序(3models.py
个文件),模型准确地反映了表格!
到目前为止,我发现的最好的方法是:
- 清除所有
migrations
个文件夹.完成! - 删除
django_migrations
表中的所有内容.完成! - 每个应用程序运行
python manage.py makemigrations --empty <app>
次.好了! - 跑
python manage.py migrate --fake
.完成!(尽管只有在每次执行makemigrations
命令后运行它时,它才有效.
Now I add a new field, run the makemigrations
command, and I receive the following error:
django.db.utils.OperationalError: (1054, "Unknown column 'accounts_plan.max_item_size' in 'field list'")
我在这件事上花了好几个小时.h**l如何初始化迁移,以便在每次迁移都不中断的情况下继续工作?
为什么会这么复杂呢?为什么没有简单的一句话:initiate_migrations_from_schema
?
EDIT:
Now things get even nastier. I truncated the django_migrations
table and deleted all the migrations
folder.
Now I try to run python manage.py migrate --fake-initial
(something I found in the DEV docs), just so it sets up all of Django's 'internal' apps (auth, session, etc) and I'm getting:
(1054, "Unknown column 'name' in 'django_content_type'")
.
Now, this "column" is not a real column. It's a @property
defined in Django's contenttypes
app. WHAT IS GOING ON HERE? Why is it identifying the name
property as a real column?