Django 1.7 - “无迁移申请”运行后迁移迁移 [英] Django 1.7 - "No migrations to apply" when run migrate after makemigrations
问题描述
class RoadmapProfile(models.Model)
pre>
user = models.OneToOneField(auth.User)
fullname = models.CharField(max_length = 100,verbose_name =全名)
创建迁移返回:
配置文件 :
0001_initial.py:
- 创建模型RoadmapProfile
当我运行迁移配置文件:
要执行的操作:
应用所有迁移:配置文件
运行迁移:
不要迁移以应用。
问题是,当我尝试打开任何与mezzanine.accounts相关的页面(例如更新帐户),它崩溃:
/ accounts / update /
中的OperationalError没有这样的列:profiles_roadmapprofile .fullname
我做错了什么?
解决方案听起来像你的初始迁移是假的,因为表已经存在(可能有一个过时的模式):
https://docs.djangoproject.com/en/1.7/topics/migrations/#adding -migrations-to-apps
这将为您的应用程序进行新的初始迁移现在,当您
运行迁移, Django将检测到您有一个初始迁移,
表示它想要创建的表已经存在,并将
迁移标记为已应用
否则你会得到一个不这样的表错误:)
你清理了应用迁移表吗?这也是未应用迁移的常见原因。
I use Django1.7 with Mezzanine. I create simple profile (according to Mezzanine documentation) stored in separate app "profiles":
class RoadmapProfile(models.Model): user = models.OneToOneField("auth.User") fullname = models.CharField(max_length=100, verbose_name="Full name")
Creation of migrations returns:
Migrations for 'profiles': 0001_initial.py: - Create model RoadmapProfile
When I run "migrate profiles":
Operations to perform: Apply all migrations: profiles Running migrations: No migrations to apply.
The issue is, when I try to open any page related to mezzanine.accounts (for example update account), it crashes with:
OperationalError at /accounts/update/ no such column: profiles_roadmapprofile.fullname
What I have done wrong?
解决方案Sounds like your initial migration was faked because the table already existed (probably with an outdated schema):
https://docs.djangoproject.com/en/1.7/topics/migrations/#adding-migrations-to-apps
"This will make a new initial migration for your app. Now, when you run migrate, Django will detect that you have an initial migration and that the tables it wants to create already exist, and will mark the migration as already applied."
Otherwise you would get an no-such-table error :)
[edit] did you clean up the applied-migrations table? That's also a common cause for non-applied migrations.
这篇关于Django 1.7 - “无迁移申请”运行后迁移迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!