2012-03-12 3 views
3

リンク先までRails Tutorialを追跡しました。ここでherokuでは、rake db:migrateで「データベース構成でアダプタが指定されていません」というエラーが発生する

は、シェルの出力です:

jrhorn424 at hook in ~/Learning/rails/rails-tutorial/demo_app on master 
$ heroku run rake db:migrate   
Running rake db:migrate attached to terminal... up, run.2 

### Snip ### 

Migrating to CreateUsers (20120310145100) 
Migrating to CreateMicroposts (20120311052021) 
rake aborted! 
database configuration does not specify adapter 

Tasks: TOP => db:schema:dump 
(See full trace by running task with --trace) 

私はHeroku quick startに相談し、グーグルのビットをやりました。私は問題がconfig/database.ymlであると思っていました。それは私の開発環境でsqlite3への参照がいっぱいです。ただし、サーバー上で、同じファイルは、とりわけ、これらの行が含まれていますデプロイされたアプリケーションを介してデータを追加する

adapter = uri.scheme 
adapter = "postgresql" if adapter == "postgres" 

は成功しますが、heroku run rake db:migrateを実行すると、まだ失敗します。

は、ここに私のGemfileです:

source 'https://rubygems.org' 

gem 'rails', '3.2.2' 

# Bundle edge Rails instead: 
# gem 'rails', :git => 'git://github.com/rails/rails.git' 

group :development do 
    gem 'sqlite3', '1.3.5' 
end 

# Gems used only for assets and not required 
# in production environments by default. 
group :assets do 
    gem 'sass-rails', '3.2.4' 
    gem 'coffee-rails', '3.2.2' 

    # See https://github.com/sstephenson/execjs#readme for more supported runtimes 
    # gem 'therubyracer' 

    gem 'uglifier', '1.2.3' 
end 

gem 'jquery-rails', '2.0.0' 

group :production do 
    gem 'pg', '0.12.2' 
end 
+0

Heroku over独自のPostgreSQLインスタンスを使用するようにdatabase.ymlファイルを起動します。この質問にGemfileを追加してください。 –

+0

ありがとう、@ RyanBigg。 Gemfileが追加されました。前述のように、サーバ上の 'database.yml'には正しいアダプタが含まれているようです。 – jrhorn424

答えて

2
私はあなたのデータベースをドロップする推薦

bundle exec rake db:drop:all 

あなたが先に行くと、お使いの環境のすべてのためのpostgresを使用し、Herokuの上でホスティングされようとしている場合。 sqlite gemを削除し、Gemfileの最上部付近に

gem 'pg' 

を含めてください。

Peform:

bundle 
bundle exec rake db:create 
bundle exec rake db:migrate 

は(あなたはすでにそれを行う方法を知っている)コミットしてもう一度プッシュしてください。

これが機能しないかどうか教えてください。

PSは、ここに私のdatabase.ymlファイルは次のようになります。私はheroku db:pushを実行したとき

# PostgreSQL v0.8.x 
# gem install pg 
development: 
    adapter: postgresql 
    encoding: unicode 
    host: localhost 
    database: health_development 
    pool: 5 
    username: volpine 
    password: password 

    # Warning: The database defined as "test" will be erased and 
    # re-generated from your development database when you run   "rake". 
    # Do not set this db to the same as development or production. 
test: 
    adapter: postgresql 
    encoding: unicode 
    host: localhost 
    database: health_test 
    pool: 5 
    username: volpine 
    password: password 

production: 
    adapter: postgresql 
    encoding: unicode 
    host: localhost 
    database: health_production 
    pool: 5 
    username: volpine 
    password: password 
+0

それはちょうどそれをする[Herokuが推薦する](http://devcenter.heroku.com/articles/how-do-i-use-sqlite3-for-development)ので、おそらく良いアドバイスです。しかし、私が知る限り、これは 'heroku run rake db:migrate'を使ってマイグレーションするリモート呼び出しには役立ちません。 – jrhorn424

+0

wbat about about: heroku run rake db:push –

+0

ありがとうございます、ありがとうございます、あなたの提案(よく、私は 'heroku db:push'をしました)私の解決に私を導きます。 – jrhorn424

0

、私はルビー1.9.2を使用するように切り替えるために私を導くtaps errorを得ました。バージョンを切り替えて新しいアプリを起動した後、私はもはやheroku run rake db:migrateからエラーを受け取ることはなく、すべて正常に機能します。

更新:私は、バージョンの不一致がdb:migrateの問題ではないことを知らされました。それは確かにdb:pushのために重要だったので、何が間違っていたのか分かりません。いずれにしても、同じGemfileと1.9.2で新しいアプリケーションを初期化すると動作します。

1

私はこれに走ったし、手動でRAILS_ENVを設定することは私のためのトリックをしたことがわかった:

heroku run RAILS_ENV=production rake db:migrate 
0

私は同じ問題を抱えていました。私はherokuアプリからRAILS_ENV環境変数を削除し、RACK_ENVを残していたために起こっていました。 RAILS_ENV =生産を追加

は、問題を修正しました:Herokuのは、あなたのdatabase.ymlのファイルを見ていない

heroku config:add RAILS_ENV=production --app XXXX-production 
0

、それはDATABASE_URLを見て - それが設定され、またはそれにタイプミスがあっていない場合、あなたはそのエラーを取得します。

私は生産のレールコンソールを開こうとしたとき、私は、このエラーに直面した私にとって
3

は、

私が与えた、

bundle exec rails c RAILS_ENV=production 

それは誤り

`resolve_hash_connection': database configuration does not specify adapter (ActiveRecord::AdapterNotSpecified) 

をスローしますが、それは時に動作します私は、与えた

RAILS_ENV=production bundle exec rails c 
関連する問題