在 database.yml 上配置 postgresql



我有一个在heroku上运行的rails web应用程序。在我的 heroku 网站仪表板中,它说我的应用程序在 postgresql 上运行,但我的 database.yml 说它在 sqlite3 上运行

default: &default
adapter: sqlite3
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000
development:
<<: *default
database: db/development.sqlite3
test:
<<: *default
database: db/test.sqlite3
production:
<<: *default
database: db/production.sqlite3

这是我的宝石文件

group :development do
gem 'sqlite3'
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
group :production do
gem 'pg'
end

我想为生产制作 adpater postgresql,这样我就可以将RAILS_MAX_THREADS更改为 25。

我不确定更改此设置是否可以擦除我的生产数据库,因此我请您帮助解决此问题。

In your database.yml 您必须配置生产环境

production:
adapter: postgresql
encoding: unicode
database: db_name
pool: 5
username: db_user
password: db_pass

您似乎尚未配置生产数据库。

production:
adapter: postgresql
database: your_database
user: your_user
password: your_password
pool: 5

您应该将数据库用户和密码保存在环境变量中。您可能会发现此文档很有帮助:https://devcenter.heroku.com/articles/getting-started-with-rails5#add-the-pg-gem

最新更新