Rails 4 - 如何在开发中使用sqlite3和使用Heroku生成PostgreSQL

six*_*bit 10 sqlite postgresql ruby-on-rails heroku ruby-on-rails-4

我正在尝试部署到Heroku但不能,因为默认的sqlite3服务器仍然存在.

检测到Heroku不支持的sqlite3 gem. https://devcenter.heroku.com/articles/sqlite3

在另一个使用Rails 3.2.13的教程中,我能够使用sqlite3作为dev db和Postgres作为生产数据库.Gemfile在Rails 4中看起来有所不同,但我修改它以使其具有:

group :development do
  # Use sqlite3 as the database for Active Record
  gem 'sqlite3'
end

group :production do
  gem 'pg'
end
Run Code Online (Sandbox Code Playgroud)

然后我更改了我的database.yml文件,以便生产部分看起来像这样:

production:
  adapter: postgresql
  database: my_production_database
  pool: 5
  timeout: 5000
Run Code Online (Sandbox Code Playgroud)

然后我跑bundle installrake db:createrake db:migrate,但我仍然无法推到的Heroku.于是,我就rake db:droprake db:createrake db:migrate,但我仍然得到同样的错误消息.

我错过了什么吗?我还需要做些什么来确保我将Postgres作为我的生产数据库并且能够使用Heroku?

Chr*_*hol 19

不要这样做.你将在未来遇到问题.在生产和开发中使用相同的数据库.记录从sqlite到postgres数据库的切换有很多资源可用.

花点时间切换.

看看这个Rails Cast.

http://railscasts.com/episodes/342-migrating-to-postgresql?view=asciicast