我在尝试向Django中的现有模型添加新字段时遇到了一个错误。它使用MySQL RDS数据库托管在弹性beanstalk上。在
当我试图访问包含新字段的模型时,出现以下错误:
(1054,“未知列”存在_model.new_字段'在'字段列表')
有没有更好的方法来处理EB上的Django移民?这是我的.config文件:
container_commands:
01_makemigrations:
command: "source /opt/python/run/venv/bin/activate && python manage.py makemigrations --noinput"
leader_only: true
02_migrate:
command: "source /opt/python/run/venv/bin/activate && python manage.py migrate --noinput"
leader_only: true
03_createsu:
command: "source /opt/python/run/venv/bin/activate && python manage.py createsu"
leader_only: true
04_collectstatic:
command: "source /opt/python/run/venv/bin/activate && python manage.py collectstatic --noinput"
有什么帮助吗?谢谢!在
原来我必须在
eb deploy
之前在本地运行python manage.py makemigrations
。这样,就创建了迁移文件,当在eb实例上运行migrate
时,它知道如何相应地更改数据库。在我的.config文件现在是:
相关问题 更多 >
编程相关推荐