原来我必须跑 python manage.py makemigrations 在当地之前 eb deploy 。这样,就可以创建迁移文件 migrate 在eb实例上运行,它知道如何相应地更改数据库。
python manage.py makemigrations
eb deploy
migrate
我的.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"