0

ずいぶん前に書いた Rails アプリを微調整しているときに、データベースを削除して、移行を最初からやり直しました。

おっと-基本的な db:setup でさえ機能しません!

私の記憶が正しければ、

$ RAILS_ENV=development bundle exec rake db:setup 
$ RAILS_ENV=development bundle exec rake db:migrate

問題は、データベースが rake/rails に認識されなくなったことだと思います。理由について何か推測はありますか?

私の database.yml は最近変更されていません!

test:
  adapter:    postgresql
  database:   argotifier_test
  username:   argotifier
  password:   start123
  host:       localhost
  pool:       5

rake タスクを実行したときのトレースは次のとおりです。

$ RAILS_ENV=test bundle exec rake db:setup --trace
** Invoke db:setup (first_time)
** Invoke db:create (first_time)
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
** Execute db:create
rake aborted!
undefined method `[]' for nil:NilClass
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/railties/databases.rake:74:in `rescue in create_database'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/railties/databases.rake:54:in `create_database'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:236:in `call'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:236:in `block in execute'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:231:in `each'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:231:in `execute'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:175:in `block in invoke_with_call_chain'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:197:in `block in invoke_prerequisites'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:195:in `each'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:195:in `invoke_prerequisites'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:174:in `block in invoke_with_call_chain'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:161:in `invoke'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:149:in `invoke_task'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:106:in `each'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:106:in `block in top_level'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:115:in `run_with_threads'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:100:in `top_level'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:78:in `block in run'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:75:in `run'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/rake-10.1.0/bin/rake:33:in `<top (required)>'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/bin/rake:23:in `load'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/bin/rake:23:in `<main>'
Tasks: TOP => db:setup => db:create


$ RAILS_ENV=test bundle exec rake db:migrate --trace
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
rake aborted!
test database is not configured
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:62:in `establish_connection'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:55:in `establish_connection'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/railtie.rb:69:in `block (2 levels) in <class:Railtie>'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/lazy_load_hooks.rb:42:in `each'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/base.rb:2190:in `<top (required)>'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/railties/databases.rake:6:in `block (2 levels) in <top (required)>'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:236:in `call'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:236:in `block in execute'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:231:in `each'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:231:in `execute'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:175:in `block in invoke_with_call_chain'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:197:in `block in invoke_prerequisites'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:195:in `each'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:195:in `invoke_prerequisites'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:174:in `block in invoke_with_call_chain'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:161:in `invoke'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:149:in `invoke_task'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:106:in `each'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:106:in `block in top_level'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:115:in `run_with_threads'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:100:in `top_level'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:78:in `block in run'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:75:in `run'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/rake-10.1.0/bin/rake:33:in `<top (required)>'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/bin/rake:23:in `load'
/Users/monkeywidget/.rbenv/versions/1.9.3-p429/bin/rake:23:in `<main>'
Tasks: TOP => db:migrate => db:load_config
4

1 に答える 1

0

rake db:test:preparetest データベースに対して実行する必要があります。

その他のオプションについては、これを確認してください。

于 2013-09-09T20:07:42.060 に答える