Rails 4 – 如何在开发中使用sqlite3和使用Heroku生成PostgreSQL
我正在尝试部署到Heroku但不能,因为默认的sqlite3服务器仍然存在。
检测到Heroku不支持的sqlite3 gem。 https://devcenter.heroku.com/articles/sqlite3
在另一个使用Rails 3.2.13的教程中,我能够使用sqlite3作为dev db和Postgres作为生产db。 Gemfile在Rails 4中看起来有所不同,但我已将其修改为具有以下内容:
group :development do # Use sqlite3 as the database for Active Record gem 'sqlite3' end group :production do gem 'pg' end
然后我更改了我的database.yml文件,以便生产部分看起来像这样:
production: adapter: postgresql database: my_production_database pool: 5 timeout: 5000
然后我运行了bundle install
和rake db:create
和rake db:migrate
但仍然无法推送到Heroku。 所以我尝试了rake db:drop
以及rake db:create
和rake db:migrate
但仍然收到相同的错误消息。
我错过了什么吗? 我还需要做些什么来确保我将Postgres作为我的生产数据库并且能够使用Heroku?
不要这样做。 你将在未来遇到问题。 在生产和开发中使用相同的数据库。 记录从sqlite到postgres数据库的交换机有很多资源可用。
花点时间切换。
看看这个Rails Cast。
http://railscasts.com/episodes/342-migrating-to-postgresql?view=asciicast
尝试将此用于生产数据库
production: adapter: postgresql host: localhost encoding: unicode database: my_production_database pool: 5 username: password:
您可以将用户名和密码留空