执行 heroku run rake db:migrate 失败,提示如下,请问该怎么解决,谢谢!
)> at /app/Rakefile:7)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
rake aborted!
Invalid DATABASE_URL
(erb):9:in rescue in <main>'
(erb):6:in
eval'
/usr/local/lib/ruby/1.9.1/erb.rb:753:in
result'
#1 楼 @Rei development: adapter: sqlite3 database: db/development.sqlite3 pool: 5 timeout: 5000
test: adapter: sqlite3 database: db/test.sqlite3 pool: 5 timeout: 5000
production: adapter: postgresql database: production pool: 5 timeout: 5000 [user@localhost config]$
#4 楼 @shangchen heroku 似乎会自动生成 production 环境的数据库配置,你把 database.yml 里的 production 数据库配置删了试试。- -。
#9 楼 @shangchen 你试试在 heroku 上手工添加一个 postgresql 数据库,然后在数据库设置里选择生成适合 activemodel 的配置,再把这个配置写到你的 database.yml 里。
用 postgresQL 数据库 Using pg:transfer to Migrate Postgres Databases heroku pg:transfer -f 本机的数据库地址 -t heroku 的数据库地址
http://nameless-savannah-7872.herokuapp.com/blog,主页是默认的rails欢迎页面,我没有动过的。这到底是哪的问题呢这就是这个地址,就算数据库没对,也应该能看到主页是吧?我是按示例做到个
太多了,麻烦高手帮忙分析一下阿,非常感谢
heroku logs:
2013-06-07T14:10:42.153871+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/railtie/configurable.rb:30:in method_missing'
2013-06-07T14:10:42.154336+00:00 app[web.1]: from script/rails:6:in
require'
2013-06-07T14:10:42.153602+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/engine.rb:438:in each'
2013-06-07T14:10:42.153602+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/engine.rb:438:in
block in eager_load!'
2013-06-07T14:10:42.154336+00:00 app[web.1]: from script/rails:6:in <main>'
2013-06-07T14:10:43.322655+00:00 heroku[web.1]: Process exited with status 1
2013-06-07T14:10:43.340656+00:00 heroku[web.1]: State changed from starting to crashed
2013-06-07T14:12:29.614765+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/blog host=nameless-savannah-7872.herokuapp.com fwd="218.194.36.91" dyno= connect= service= status=503 bytes=
2013-06-07T14:12:37.461311+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=nameless-savannah-7872.herokuapp.com fwd="218.194.36.91" dyno= connect= service= status=503 bytes=
2013-06-07T14:12:37.994196+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=nameless-savannah-7872.herokuapp.com fwd="218.194.36.91" dyno= connect= service= status=503 bytes=
2013-06-07T14:14:48.197668+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/blog%EF%BC%8C%E4%B8%BB%E9%A1%B5%E6%98%AF%E9%BB%98%E8%AE%A4%E7%9A%84rails%E6%AC%A2%E8%BF%8E%E9%A1%B5%E9%9D%A2%EF%BC%8C%E6%88%91%E6%B2%A1%E6%9C%89%E5%8A%A8%E8%BF%87%E7%9A%84%E3%80%82%E8%BF%99%E5%88%B0%E5%BA%95%E6%98%AF%E5%93%AA%E7%9A%84%E9%97%AE%E9%A2%98%E5%91%A2 host=nameless-savannah-7872.herokuapp.com fwd="211.155.120.241" dyno= connect= service= status=503 bytes=
2013-06-07T14:14:51.690765+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=nameless-savannah-7872.herokuapp.com fwd="211.155.120.241" dyno= connect= service= status=503 bytes=
2013-06-07T14:14:52.088487+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=nameless-savannah-7872.herokuapp.com fwd="211.155.120.241" dyno= connect= service= status=503 bytes=
2013-06-07T14:16:59.043851+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/blog host=nameless-savannah-7872.herokuapp.com fwd="112.91.70.213" dyno= connect= service= status=503 bytes=
2013-06-07T14:16:59.851819+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=nameless-savannah-7872.herokuapp.com fwd="112.91.70.213" dyno= connect= service= status=503 bytes=
2013-06-07T14:17:01.069446+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=nameless-savannah-7872.herokuapp.com fwd="112.91.70.213" dyno= connect= service= status=503 bytes=
2013-06-07T14:17:02.285538+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=nameless-savannah-7872.herokuapp.com fwd="112.91.70.213" dyno= connect= service= status=503 bytes=
2013-06-07T14:17:02.993450+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=nameless-savannah-7872.herokuapp.com fwd="112.91.70.213" dyno= connect= service= status=503 bytes=
2013-06-07T14:20:44.920000+00:00 heroku[web.1]: State changed from crashed to starting
2013-06-07T14:20:47.473386+00:00 heroku[web.1]: Starting process with command
bundle exec rails server -p 13175
2013-06-07T14:20:57.147919+00:00 app[web.1]: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5)
2013-06-07T14:20:57.148644+00:00 app[web.1]: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5)
2013-06-07T14:21:00.780422+00:00 app[web.1]: => Booting WEBrick
2013-06-07T14:21:00.780422+00:00 app[web.1]: => Rails 3.2.12 application starting in production on http://0.0.0.0:13175
2013-06-07T14:21:00.780422+00:00 app[web.1]: => Call with -d to detach
2013-06-07T14:21:00.780422+00:00 app[web.1]: => Ctrl-C to shutdown server
2013-06-07T14:21:00.784736+00:00 app[web.1]: Exiting
2013-06-07T14:21:00.786789+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/application/configuration.rb:115:in
database_configuration'
2013-06-07T14:21:00.786789+00:00 app[web.1]: (erb):9:in rescue in <main>': Invalid DATABASE_URL (RuntimeError)
2013-06-07T14:21:00.786789+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/lazy_load_hooks.rb:36:in
execute_hook'
2013-06-07T14:21:00.786996+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/lazy_load_hooks.rb:42:in run_load_hooks'
2013-06-07T14:21:00.786996+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/base.rb:720:in
'
2013-06-07T14:21:00.786996+00:00 app[web.1]: from /app/app/models/post.rb:1:in <top (required)>'
2013-06-07T14:21:00.786996+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:251:in
require'
2013-06-07T14:21:00.786996+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:251:in block in require'
2013-06-07T14:21:00.786996+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:236:in
load_dependency'
2013-06-07T14:21:00.786996+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:251:in require'
2013-06-07T14:21:00.786789+00:00 app[web.1]: from (erb):6:in
instance_eval'
2013-06-07T14:21:00.787154+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/inflector/methods.rb:230:in
block in constantize'
2013-06-07T14:21:00.786789+00:00 app[web.1]: from /usr/local/lib/ruby/1.9.1/erb.rb:753:in eval'
2013-06-07T14:21:00.786789+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/railtie.rb:78:in
block (2 levels) in class:Railtie'
2013-06-07T14:21:00.786789+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/lazy_load_hooks.rb:42:in each'
2013-06-07T14:21:00.786996+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:359:in
require_or_load'
2013-06-07T14:21:00.786789+00:00 app[web.1]: from /usr/local/lib/ruby/1.9.1/erb.rb:753:in result'
2013-06-07T14:21:00.787154+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:190:in
const_missing'
2013-06-07T14:21:00.786789+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/lazy_load_hooks.rb:43:in block in run_load_hooks'
2013-06-07T14:21:00.786996+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:192:in
block in const_missing'
2013-06-07T14:21:00.786996+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:502:in load_missing_constant'
2013-06-07T14:21:00.787154+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:190:in
each'
2013-06-07T14:21:00.787154+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/inflector/methods.rb:260:in safe_constantize'
2013-06-07T14:21:00.787154+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/action_controller/metal/params_wrapper.rb:152:in
_default_wrap_model'
2013-06-07T14:21:00.787154+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/action_controller/metal/params_wrapper.rb:133:in inherited'
2013-06-07T14:21:00.787579+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/abstract_controller/railties/routes_helpers.rb:7:in
block (2 levels) in with'
2013-06-07T14:21:00.787745+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/engine.rb:438:in block in eager_load!'
2013-06-07T14:21:00.788112+00:00 app[web.1]: from /app/config/environment.rb:5:in
'
2013-06-07T14:21:00.788295+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/commands.rb:50:in tap'
2013-06-07T14:21:00.787745+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/engine.rb:436:in
each'
2013-06-07T14:21:00.787745+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/initializable.rb:54:in each'
2013-06-07T14:21:00.788112+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:51:in
initialize'
2013-06-07T14:21:00.787579+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/action_controller/railties/paths.rb:7:in block (2 levels) in with'
2013-06-07T14:21:00.787579+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:225:in
require_dependency'
2013-06-07T14:21:00.787154+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/inflector/methods.rb:229:in each'
2013-06-07T14:21:00.787579+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:251:in
require'
2013-06-07T14:21:00.787154+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/action_controller/metal/params_wrapper.rb:169:in _set_wrapper_defaults'
2013-06-07T14:21:00.787579+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:236:in
load_dependency'
2013-06-07T14:21:00.787579+00:00 app[web.1]: from /app/app/controllers/posts_controller.rb:1:in <top (required)>'
2013-06-07T14:21:00.787579+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:251:in
block in require'
2013-06-07T14:21:00.787745+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/engine.rb:436:in eager_load!'
2013-06-07T14:21:00.787154+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/inflector/methods.rb:229:in
constantize'
2013-06-07T14:21:00.787154+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/core_ext/string/inflections.rb:66:in safe_constantize'
2013-06-07T14:21:00.787579+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:251:in
require'
2013-06-07T14:21:00.787745+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/initializable.rb:55:in block in run_initializers'
2013-06-07T14:21:00.788112+00:00 app[web.1]: from /app/config.ru:3:in
block in '
2013-06-07T14:21:00.787745+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/engine.rb:439:in block (2 levels) in eager_load!'
2013-06-07T14:21:00.788295+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/server.rb:304:in
wrapped_app'
2013-06-07T14:21:00.787745+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/engine.rb:438:in each'
2013-06-07T14:21:00.788112+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:51:in
instance_eval'
2013-06-07T14:21:00.788295+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:40:in eval'
2013-06-07T14:21:00.788599+00:00 app[web.1]: from script/rails:6:in
require'
2013-06-07T14:21:00.787745+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/initializable.rb:30:in run'
2013-06-07T14:21:00.788112+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/railtie/configurable.rb:30:in
method_missing'
2013-06-07T14:21:00.787579+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:359:in require_or_load'
2013-06-07T14:21:00.788112+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/initializable.rb:54:in
run_initializers'
2013-06-07T14:21:00.788112+00:00 app[web.1]: from /app/config.ru:in <main>'
2013-06-07T14:21:00.787745+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/initializable.rb:30:in
instance_exec'
2013-06-07T14:21:00.788112+00:00 app[web.1]: from /app/config.ru:3:in require'
2013-06-07T14:21:00.788295+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/commands.rb:50:in
'
2013-06-07T14:21:00.788112+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/application.rb:136:in initialize!'
2013-06-07T14:21:00.788112+00:00 app[web.1]: from /app/config.ru:in
new'
2013-06-07T14:21:00.787579+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:313:in depend_on'
2013-06-07T14:21:00.787745+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/application/finisher.rb:53:in
block in module:Finisher'
2013-06-07T14:21:00.788295+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/server.rb:200:in app'
2013-06-07T14:21:00.788295+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/commands/server.rb:70:in
start'
2013-06-07T14:21:00.788295+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/commands.rb:55:in block in <top (required)>'
2013-06-07T14:21:00.788599+00:00 app[web.1]: from script/rails:6:in
'
2013-06-07T14:21:00.788295+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:40:in parse_file'
2013-06-07T14:21:00.788295+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/commands/server.rb:46:in
app'
2013-06-07T14:21:00.788295+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/server.rb:254:in `start'
2013-06-07T14:21:02.481410+00:00 heroku[web.1]: Process exited with status 1
2013-06-07T14:21:02.502216+00:00 heroku[web.1]: State changed from starting to crashed
遇到和你相同的问题,不过解决办法不一样,附上我的解决方法:
$ heroku addons:add heroku-postgresql:dev
$ heroku config | grep HEROKU_POSTGRESQL
我的输出显示是:
$ HEROKU_POSTGRESQL_NAVY_URL: postgres://root@root
则这个参数是 HEROKU_POSTGRESQL_NAVY_URL
$ heroku pg:promote HEROKU_POSTGRESQL_NAVY_URL
heroku run rake db:migrate
就可以了!