Makemigrations无法检测到弹性beantalk的变化

时间:2018-10-26 14:37:34

标签: django postgresql amazon-web-services amazon-elastic-beanstalk

我正在Elastic Beanstalk上运行Django 1.11应用。

我有一个模型Profile作为应用程序grams的一部分,并且向该模型添加了一个字段email_verified。当我在本地进行makemigrations时,它会立即拿起零钱。当我使用eb deploy进入弹性beantalk时,它将运行makemigrations但未发现任何更改,然后运行migration并且未发现任何更改。

此服务器已经运行了几个月,并且已经成功进行了多次迁移。

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

    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

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

1 个答案:

答案 0 :(得分:0)

@Daniel Roseman是正确的!

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

现在一切正常。