【发布时间】:2015-07-10 21:24:44
【问题描述】:
根据此处的文档: https://docs.djangoproject.com/en/1.8/topics/migrations/ 它说:
migrate, which is responsible for applying migrations, as well as unapplying and listing their status.
和
makemigrations, which is responsible for creating new migrations based on the changes you have made to your models.
据我所知,我先做
makemigrations
创建迁移文件然后做
migrate
实际应用迁移?
请注意,我刚刚开始我的 Django 项目,并将我的应用程序添加到我的“已安装应用程序”列表中。之后,我做到了
python manage.py runserver
它说
You have unapplied migrations; your app may not work properly until they are applied. Run 'python manage.py migrate' to apply them.
它没有提到任何关于运行 makemigrations 的内容。
【问题讨论】:
-
django 框架需要一些数据库表 - 例如:会话、content_type、已经为其创建迁移的站点。您看到的消息是这些“默认”迁移尚未应用。因此,您将在第一次启动服务器之前运行 migrate
-
@karthikr 哦,好吧。所以在我的情况下,由于我甚至在执行初始“迁移”之前就将我的应用程序添加到了“installed_apps”,这是否意味着我现在应该先运行“makemigration”然后再执行“迁移”?
-
是的。那是为您的应用程序创建迁移的时间。下一步是应用这些创建的迁移
标签: django database-migration django-south schema-migration