将Django开发数据库(.sql3)迁移到Heroku [英] Migrate Django development database (.sql3) to Heroku

查看:217
本文介绍了将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数据库和通过pgbackups工具将postgre数据库转储到Heroku ):

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):


  1. 创建您的sql3数据库的转储作为一个json文件

  2. 安装PostgreSql并在 bin code>路径环境变量,创建一个postgre用户和数据库(或只是计划使用您安装postgresql时创建的初始超级用户帐户)

  3. 将您的 settings.py 更新为引用您新创建的postgre数据库(注意'HOST'可能需要设置为'localhost''user'是您的postgre用户登录)

  4. 运行 python manage.py syncdb 启动您的新postgre db

  5. 可选:如有必要,截断你的postgre db 的内容类型

  6. 从步骤1加载转储(如果您有fixture问题,见这里

  7. 现在你有一个工作的postgre本地数据库。 要迁移,请先创建postgre转储

  8. 将您的postgre转储发布到可通过URL访问的位置(例如上一个链接中建议的下拉框或亚马逊s3)。

  9. 执行 pgbackups restore命令,引用您的转储网址

  10. 您的英雄应用程序现在应该引用本地数据库的内容。

  1. Create a dump of your sql3 database as a json file
  2. With PostgreSql installed and with its bin directory in the Path environment variable, create a postgre user and database (or just plan on using your initial super user account created upon installing postgresql)
  3. 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)
  4. run python manage.py syncdb to initiate your new postgre db
  5. Optional: if necessary, truncate your postgre db of contenttypes
  6. load your dump from step 1 (if you have fixture issues, see here)
  7. Now you have a working postgre local db. To migrate, first create a postgre dump
  8. Post your postgre dump somewhere accessible by URL (such as drop box or amazon s3 as suggested in previous link).
  9. Perform pgbackups restore command, referencing your dump url
  10. Your heroku app should now reference the contents of your local db.

这篇关于将Django开发数据库(.sql3)迁移到Heroku的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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