0
0

More than 3 years have passed since last update.

Railsでsqlite3からpsglに乗り換えてみた!(途中から)

Posted at

今回やること

(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したらうまくいきました!

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0