本文介绍了将Django开发数据库(.sql3)迁移到Heroku的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将Django .sql3开发数据库迁移到heroku?
How does one migrate their Django .sql3 development database to heroku?
每我试过: heroku pg:psql --app sblic< database.sql3
,但我的Django管理员没有显示任何新的上传(即使在syncdb / migrate /或collectstatic
Per here, and here I tried: heroku pg:psql --app sblic < database.sql3
but my Django admin shows no new uploads (even after syncdb/migrate/ or collectstatic
推荐答案
p>也许可能有一种方法可以将sql3文件直接上传到Heroku,但是我以最清晰的确定路径(将本地sql3数据库转换为postgre数据库和):
Perhaps there may be a way to directly upload an sql3 file to Heroku, but I went with the path of clearest certainty (convert local sql3 db to postgre db and upload a dump of postgre db to Heroku via pgbackups tool):
- 安装PostgreSql并在
bin
code>路径环境变量,(或只是计划使用您安装postgresql时创建的初始超级用户帐户) - 将您的
settings.py
更新为(注意'HOST'
可能需要设置为'localhost'
,'user'
是您的postgre用户登录) - 运行
python manage.py syncdb
启动您的新postgre db - 可选:如有必要,的内容类型
- (如果您有fixture问题,)
- 现在你有一个工作的postgre本地数据库。
- 将您的postgre转储发布到可通过URL访问的位置(例如上一个链接中建议的下拉框或亚马逊s3)。
- 执行
- 您的英雄应用程序现在应该引用本地数据库的内容。
- Create a dump of your sql3 database as a json file
- With PostgreSql installed and with its
bin
directory in thePath
environment variable, create a postgre user and database (or just plan on using your initial super user account created upon installing postgresql) - Update your
settings.py
with a reference to your newly created postgre database (note,'HOST'
may need to be set as'localhost'
,'user'
is your postgre user login) - run
python manage.py syncdb
to initiate your new postgre db - Optional: if necessary, truncate your postgre db of contenttypes
- load your dump from step 1 (if you have fixture issues, see here)
- Now you have a working postgre local db. To migrate, first create a postgre dump
- Post your postgre dump somewhere accessible by URL (such as drop box or amazon s3 as suggested in previous link).
- Perform pgbackups restore command, referencing your dump url
- Your heroku app should now reference the contents of your local db.
这篇关于将Django开发数据库(.sql3)迁移到Heroku的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!