今回やること
(psglはインストールされている前提で話を進めます!)
- gem "pg"
- config/database.ymlを変更
- エラーにどのように対応したか
gem "pg"を入れる
sqlite3はコメントアウトするか、削除
gem 'pg', '~> 0.18.4'
bundle installをし、すんなり行けばおっけー!ちなみに僕はすんなりいきませんでした。それはエラーにどのように対応したかの項目で紹介します!
config/database.ymlを変更
default: &default
adapter: postgresql #変更
encoding: unicode
pool: 5
host: localhost #追加
development:
<<: *default
database: appname_development # appnameのところは、db/development.sqliteになっているはずなので、変更
test:
<<: *default
database: appname_test #上記と同様
エラーにどのように対応したか
gem "pg"の時にめちゃめちゃ長いエラー
解消方法 ターミナルもしくはテキストエディターの再起動
`
省略
`
An error occurred while installing pg (1.2.0), and Bundler cannot continue.
Make sure that `gem install pg -v '1.2.0' --source 'https://rubygems.org/'` succeeds before bundling.
bundle exec rails db:createしようとしたら、すでにあると言われてしまったのでconfig/database.ymlのappnnameをrenameしたらうまくいきました!