【问题标题】:Rails - psql deploy on herokuRails - 在heroku上部署psql
【发布时间】:2015-10-27 04:36:40
【问题描述】:

我在 Heroku 上有一个带有 PSQL 数据库的 rails 4 应用程序。

这一切在开发中都很好,但我第一次尝试使用数据库中的内容发布应用程序。

我最近在本地和 heroku 中重置了数据库。并且还做了:

heroku ran rake:db migrate

然后我在我的文章资源中创建了第一篇文章,并提交、推送并推送到 heroku。我希望看到该文章显示(因为它在我的本地主机中)。

但是,当我以生产模式访问本地主机或访问已发布的站点时,文章不存在。

关于如何使用您想要的数据库内容推送到 heroku,我是否缺少步骤?是否需要做一些事情才能使生产数据库识别开发数据库?不确定发布生产数据库的步骤。

在我的 database.yml 文件中,我有:

staging:
  adapter: postgresql
  encoding: unicode
  database: vh_staging
  pool: 5
  #username: vh

  #host: localhost

development:
  adapter: postgresql
  encoding: unicode
  database: vh_development
  pool: 5
  #username: vh

test: &test
  adapter: postgresql
  encoding: unicode
  database: vh_test
  pool: 5
  #username: vh

production:
  adapter: postgresql
  encoding: unicode
  database: vh_production
  pool: 5
  #username: vh

【问题讨论】:

  • 尝试在终端中运行heroku logs,看看会发生什么。
  • 渲染所有视图并检查登录状态。日志中没有提到数据库。应该有吗?

标签: ruby-on-rails heroku psql


【解决方案1】:

你只推送你的代码,而不是数据库数据。

【讨论】:

  • 如何让它识别数据库数据?
  • 可能有文章可以帮到你blog.heroku.com/archives/2009/3/18/…
  • db:push 不是有效的 heroku 命令。进一步研究其他尝试。我的 heroku 帐户可以识别附加的数据库 - 但不确定需要做什么才能使其同步
【解决方案2】:

试试seed

heroku run rake db:push
heroku pg:reset DATABASE
heroku run rake db:seed

您应该在文件db/seeds.ru 中将您的数据作为ruby 代码来执行此操作。

【讨论】:

    猜你喜欢
    • 2012-04-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-02
    • 2016-10-12
    相关资源
    最近更新 更多