0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

bin/rails db:migrate でエラー@ActionMailer構築中

Posted at

エラーメッセージ

yukiya025:~/workspace (mailer) $ rake db:migrate
rake aborted!
PG::ConnectionBad: could not connect to server: Connection refused
        Is the server running locally and accepting
        connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `initialize'
...
...
...

エラーの原因

  1. PosgreSQLサービス自体が動いていない
  2. postgresqlに必要なデータベース (test, development, productionの3つ) がなかった
  3. config/database.ymlがpostgresqlのときの記法ではなく、sqlite3のときの記法のままだった

#「1. PosgreSQLサービス自体が~」の対処

yukiya025:~/workspace (mailer) $ psql
psql: could not connect to server: Connection refused

$ psql でPosgreSQLが動いていないことが判明したので

$ sudo service postgresql start

を打つ。

「2. postgresqlに必要なデータベース~」の対処

test, development, productionの3つのデータベースをpospresql開始後 ($ psqlを打った後)に作成する。

yukiya025:~/workspace (mailer) $ psql
psql (9.3.15)
Type "help" for help.
ubuntu=# create database test; 
CREATE DATABASE
ubuntu=# create database development; 
CREATE DATABASE
ubuntu=# create database production; 
CREATE DATABASE

「3. config/database.ymlがpostgresql~」の対処

database.ymlの各データベース (test, development, production) の書き方を以下のようなpostgresql記法にする。

config/database.yml
database: test
database: development
database: production

上記3つの対処が終わったら$ rake db:migrate!

$ rake db:migrateで以下のようになったら成功ですd(>u< )

yukiya025:~/workspace (mailer) $ rake db:migrate
== 20170805062406 CreateUsers: migrating ======================================
-- create_table(:users)
-> 0.0117s
== 20170805062406 CreateUsers: migrated (0.0117s) =============================
0
0
1

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?