我制作了一个.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,然后提交migrations文件夹解决了此问题。