python - Elastic Beanstalk Django 迁移不起作用
问题描述
我做了一个.ebextensions/02_python.config
文件:
container_commands:
01_migrate:
command: "source /opt/python/run/venv/bin/activate && python manage.py migrate --noinput"
leader_only: true
02_createsu:
command: "source /opt/python/run/venv/bin/activate && python manage.py createsu"
leader_only: true
03_collectstatic:
command: "source /opt/python/run/venv/bin/activate && python manage.py collectstatic --noinput"
但是当我运行时eb deploy
,它会抛出以下错误:
Creating application version archive "app-8987-200210_133822".
Uploading vspmfinal/app-8987-200210_133822.zip to S3. This may take a while.
Upload Complete.
2020-02-10 08:08:27 INFO Environment update is starting.
2020-02-10 08:08:52 INFO Deploying new version to instance(s).
2020-02-10 08:09:03 ERROR [Instance: i-0ba93a0edfd159030] Command failed on instance. Return code: 1 Output: (TRUNCATED)...ack(traceback) from exc_value
File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: relation "accounts_user" does not exist.
container_command 01_migrate in .ebextensions/02_python.config failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.
2020-02-10 08:09:03 INFO Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].
2020-02-10 08:09:03 ERROR Unsuccessful command execution on instance id(s) 'i-0ba93a0edfd159030'. Aborting the operation.
2020-02-10 08:09:03 ERROR Failed to deploy application.
我的应用名称是帐户。我通过覆盖 Django 的用户类创建了自己的用户类。我究竟做错了什么?为什么迁移不起作用?我是第一次创建这个应用程序。
解决方案
通过在本地运行 makemigrations 然后提交迁移文件夹解决了这个问题。
推荐阅读
- python-3.x - 在 tf.tensor 中赋值
- apache-spark - spark.sql.autoBroadcastJoinThreshold 中的错字...?
- css - CSS仅选择无序列表中的第一个孩子
- zendesk - Zendesk 中是否有任何 REST API 来获取未读消息计数?
- javascript - 为数组中的所有 img src 添加前缀
- linux - 从 fd_set 中提取文件描述符
- excel - 合并单元格,除非单元格包含某些文本
- ios - 如果 modalPresentationStyle 设置为 .custom,UIKit 将在视图控制器演示期间使用什么动画
- php - 如何为自定义帖子类型类别获取当前类别的父类别
- leaflet - React 中的 LeafletSlider