【发布时间】:2015-09-06 04:36:47
【问题描述】:
我在 Elastic Beanstalk 上设置了我的 Django 应用程序,最近对我希望现在应用到实时数据库的数据库进行了更改。我知道我需要将其设置为容器命令,在检查数据库后,我可以看到迁移已运行,但我不知道如何对迁移进行更多控制。例如,我只希望在必要时运行迁移,但据我了解,假设该命令仍列在配置文件中,容器将在每次部署时运行迁移。此外,在某些情况下,我会在迁移期间获得一些选项,例如:
Any objects realted to these content types by a foreign key will also be deleted.
Are you sure you want to delete these content types?
If you're unsure, answer 'no'
如何设置容器命令以在部署阶段使用 yes 响应此问题?
这是我当前的配置文件
container_commands:
01_migrate:
command: 'source /opt/python/run/venv/bin/actiate && python app/manage.py makemigrations'
command: 'source /opt/python/run/venv/bin/activate && python app/manage.py migrate'
有没有办法将这 2 个命令设置为仅在必要时运行并响应我在迁移期间收到的是/否选项?
【问题讨论】:
-
我认为这不是正确的方法!您应该在本地
makemigrations然后将迁移推送到生产环境。在部署期间应用迁移。您可以在本地进行所有决策。如果错误地编写了错误的模型,最终可能会丢失数据。
标签: python django amazon-web-services