【问题标题】:database "db/development.sqlite3" does not exist - how to fix?数据库“db/development.sqlite3”不存在 - 如何修复?
【发布时间】:2016-10-08 14:20:29
【问题描述】:

一位朋友在 Heroku 上部署了我的应用程序,它在那里运行良好。但我无法在本地服务器上打开我的应用程序。任何人都可以帮忙吗?

在本地主机上时,我收到以下错误消息:

ActiveRecord::NoDatabaseError 致命:数据库“db/development.sqlite3”不存在

提取的源代码(在 #661 行附近):

    rescue ::PG::Error => error
      if error.message.include?("does not exist")
        raise ActiveRecord::NoDatabaseError.new(error.message, error)
      else
        raise
      end

【问题讨论】:

  • rake db:create && rake db:migrate
  • 我试过了,得到了这个答案:rake db:create rake aborted! ActiveRecord::NoDatabaseError: FATAL: 数据库“db/development.sqlite3”不存在 PG::ConnectionBad: FATAL: 数据库“db/development.sqlite3”不存在
  • 我不知道我使用的是哪个适配器。 Postgres,因为它是 heroku 和 sqlite 运行的,因为它是 ruby​​ on rails 的数据库 - 如果我没记错的话。

标签: ruby-on-rails heroku


【解决方案1】:

更新您的database.yml

default: &default
  adapter: postgresql
  encoding: utf8

development:
  <<: *default
  database: your_app_development
  username: your_usernmae
  password: your_password

【讨论】:

    【解决方案2】:

    我通过将 database.yml 文件更改为您想要创建的数据库的名称来解决这个问题,例如数据库:my_app_development 例如:

    development:
      <<: *default
      database: ***_development
    

    您需要更改数据库:并运行rails db:create 然后rails db:migrate RAILS_ENV=development

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-10-29
      • 2020-09-04
      • 2012-12-12
      • 2013-02-28
      • 1970-01-01
      • 1970-01-01
      • 2016-03-16
      相关资源
      最近更新 更多