通过CircleCI将Django应用程序部署到Heroku:如何迁移数据库? [英] Deploying Django app to Heroku via CircleCI: How to migrate database?

查看:80
本文介绍了通过CircleCI将Django应用程序部署到Heroku:如何迁移数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在部署Django应用时,如何自动运行 python manage.py makemigrations python manage.py migration 通过CircleCI到Heroku。似乎所有命令都在CircleCI本地运行,但不是在生产环境中已部署的应用程序上运行。

How can I run python manage.py makemigrations and python manage.py migrate automatically when deploying a Django app to Heroku via CircleCI. It seems all commands run local to CircleCI, but not on the deployed application in production.

有办法吗?

推荐答案

python manage.py makemigrations 应该在本地运行,并且您可以连同代码一起提交迁移文件。

python manage.py makemigrations should be running locally, and you may commit the migration files along with the code.

重新进行迁移,打开您的 Procfile 并添加以下行: release:python manage.py migration
这将告诉Heroku在部署新版本的代码之前进行迁移。

Regaridng the migrations, open your Procfile and add this line: release: python manage.py migrate. This will tell Heroku to migrate before deploying a new version of your code.

这篇关于通过CircleCI将Django应用程序部署到Heroku:如何迁移数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆