迁移未检测到弹性豆茎的变化



我在 Elastic Beanstalk 上运行一个 Django 1.11 应用程序。

我有一个模型Profile作为应用程序grams的一部分,并向模型添加了一个字段email_verified。当我在本地运行 makemigration 时,它会立即获取更改。当我使用eb deploy推送到弹性 beanstalk 时,它会运行 makemigrations 但没有发现任何更改,然后运行迁移并且没有发现任何更改。

此服务器已运行数月,并且已成功迁移。

下面是部署后尝试登录后的错误消息。

Internal Server Error: /signin/
Traceback (most recent call last):
File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/db/models/fields/related_descriptors.py", line 385, in __get__
rel_obj = getattr(instance, self.cache_name)
AttributeError: 'User' object has no attribute '_profile_cache'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
psycopg2.ProgrammingError: column grams_profile.email_verified does not exist
LINE 1: ...ofile"."user_id", "grams_profile"."phone_number", "grams_pro...

下面是部署脚本:

container_commands:
01_makemigrations:
command: "source /opt/python/run/venv/bin/activate && python manage.py makemigrations --noinput"
leader_only: true
02_makemigrationsgrams:
command: "source /opt/python/run/venv/bin/activate && python manage.py makemigrations grams --noinput"
leader_only: true
03_migrate:
command: "source /opt/python/run/venv/bin/activate && python manage.py migrate --noinput"
leader_only: true
04_createsu:
command: "source /opt/python/run/venv/bin/activate && python manage.py createsu"
leader_only: true
05_collectstatic:
command: "source /opt/python/run/venv/bin/activate && python manage.py collectstatic --noinput"
leader_only: true
option_settings:
- namespace: aws:elasticbeanstalk:container:python:staticfiles
option_name: /static/
value: static/
packages:
yum:
postgresql95-devel: []
files:
"/opt/python/log/django.log" :
mode: "000666"
owner: ec2-user
group: ec2-user
content: |
# Django Log File
"/etc/httpd/conf.d/wsgi_custom.conf":
mode: "000644"
owner: root
group: root
content: |
WSGIPassAuthorization On

请让我知道我可以提供帮助的任何其他信息。

@Daniel罗斯曼是正确的!

我从我的 .ebignore 文件中删除了/migrations/,但将其保留在我的 .gitignore 文件中,以确保它们不会以 git 结束。

现在一切正常。

最新更新