数据库"db/development.sqlite3"不存在-如何修复?

3

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

当我访问localhost时,出现以下错误信息:

ActiveRecord::NoDatabaseError FATAL: 数据库 "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

1
rake db:create && rake db:migrate - Andrey Deineko
我尝试了,并得到了这个答案:rake db:create rake中止! ActiveRecord :: NoDatabaseError:致命错误:数据库“db / development.sqlite3”不存在PG :: ConnectionBad:致命错误:数据库“db / development.sqlite3”不存在 - Nikita
我不知道该使用哪个适配器。Postgres,因为Heroku运行在此上,并且SQLite,因为它是Ruby on Rails的数据库 - 如果我没记错的话。 - Nikita
2个回答

0

请更新您的database.yml文件

default: &default
  adapter: postgresql
  encoding: utf8

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

0
我通过更改 database.yml 文件来解决这个问题,将其实际上设置为您想要创建的数据库名称,例如 database: my_app_development。
development:
  <<: *default
  database: ***_development

你需要更改数据库,并运行rails db:create 接着运行rails db:migrate RAILS_ENV=development


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接