【发布时间】:2016-02-18 23:05:41
【问题描述】:
我正在开发一个已经上线数月的 django 项目。没有更改设置文件或环境本身。
我最近向模型添加了一个字段,但是当我将它部署到我的 Amazon Elastic Beanstalk 环境时,它无法将更改迁移到数据库。我收到以下错误消息:
Synchronizing apps without migrations:
Creating tables...
Running deferred SQL...
Installing custom SQL...
Running migrations:
No migrations to apply.
Your models have changes that are not yet reflected in a migration, and so won't be applied.
Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.
现在错误消息可能听起来很明显,但问题是我将数据库从生产服务器复制到本地数据库服务器并再次尝试migrate 命令,Voila 在本地工作。没有关于正在更改模型的错误消息。
当我运行makemigrations 时,我得到No changes detected.。我还为我项目中的每个应用程序尝试了makemigrations <app>。还是说No changes detected。
总结一下:
我对模型进行了更改,对它进行了新的迁移,我尝试在生产服务器上迁移它,结果出错。我尝试在本地服务器上使用数据库的精确副本,它工作正常。
想法?
编辑:
这似乎与ImageField 有关。我添加到模型中的字段是 ImageField,但是当我删除它,然后测试添加 CharField 和 FileField 时,迁移工作正常。
当我随后修改FileField 并将其变为ImageField 时,migrate 错误返回。
非常混乱。
【问题讨论】:
标签: django amazon-web-services amazon-rds django-migrations amazon-elastic-beanstalk