0

我对heroku很陌生,遇到了一些困难。我终于将 mysql db 转换为 postgres。当我运行我的应用程序时,它在本地运行良好,我收到以下错误。

2013-05-10T21:46:12.982992+00:00 app[web.1]: Connecting to database specified by DATABASE_URL
2013-05-10T21:46:12.982992+00:00 app[web.1]: => Call with -d to detach
2013-05-10T21:46:13.116415+00:00 app[web.1]: [2013-05-10 21:46:13] INFO  ruby 1.9.2 (2011-07-09) [x86_64-linux]
2013-05-10T21:46:13.116264+00:00 app[web.1]: [2013-05-10 21:46:13] INFO  WEBrick 1.3.1
2013-05-10T21:46:13.116832+00:00 app[web.1]: [2013-05-10 21:46:13] INFO  WEBrick::HTTPServer#start: pid=2 port=43445
2013-05-10T21:49:16.585598+00:00 heroku[api]: Starting process with command `bundle exec rake db:migrate` by ca@gmail.com
2013-05-10T21:49:18.405782+00:00 heroku[run.3511]: Awaiting client
2013-05-10T21:49:18.451809+00:00 heroku[run.3511]: Starting process with command `bundle exec rake db:migrate`
2013-05-10T21:49:19.722157+00:00 heroku[run.3511]: State changed from starting to up
2013-05-10T21:49:24.823706+00:00 heroku[run.3511]: Process exited with status 0
2013-05-10T21:49:24.838197+00:00 heroku[run.3511]: State changed from up to complete
2013-05-10T21:49:28.690081+00:00 app[web.1]: Started GET "/" for 98.210.56.231 at 2013-05-10 21:49:28 +0000
2013-05-10T21:49:28.835387+00:00 app[web.1]: Processing by SammichesController#index as HTML
2013-05-10T21:49:29.345160+00:00 heroku[router]: at=info method=GET path=/assets/application-1b13569e9620782f423d4cd3ce931750.css host=powerful-plateau-7517.herokuapp.com fwd="98.210.56.231" dyno=web.1 connect=28ms service=7ms status=200 bytes=0
2013-05-10T21:49:29.010552+00:00 app[web.1]:   Rendered sammiches/index.html.erb within layouts/application (39.1ms)
2013-05-10T21:49:29.012097+00:00 app[web.1]: Completed 200 OK in 176ms (Views: 65.4ms | ActiveRecord: 20.2ms)
2013-05-10T21:49:29.394490+00:00 heroku[router]: at=info method=GET path=/assets/application-9d330e31ec44ccdd3433e817066e781f.js host=powerful-plateau-7517.herokuapp.com fwd="98.210.56.231" dyno=web.1 connect=3ms service=74ms status=200 bytes=100217
2013-05-10T21:49:29.020750+00:00 heroku[router]: at=info method=GET path=/ host=powerful-plateau-7517.herokuapp.com fwd="98.210.56.231" dyno=web.1 connect=5ms service=367ms status=304 bytes=0
2013-05-10T21:49:31.116343+00:00 heroku[router]: at=info method=GET path=/favicon.ico host=powerful-plateau-7517.herokuapp.com fwd="98.210.56.231" dyno=web.1 connect=6ms service=17ms status=200 bytes=0
2013-05-10T21:49:32.105024+00:00 heroku[router]: at=info method=GET path=/sammiches/random host=powerful-plateau-7517.herokuapp.com fwd="98.210.56.231" dyno=web.1 connect=2ms service=84ms status=500 bytes=643
2013-05-10T21:49:32.023752+00:00 app[web.1]: Started GET "/sammiches/random" for 98.210.56.231 at 2013-05-10 21:49:32 +0000
2013-05-10T21:49:32.049329+00:00 app[web.1]: Processing by SammichesController#random as HTML
2013-05-10T21:49:32.097263+00:00 app[web.1]: Completed 500 Internal Server Error in 48ms
2013-05-10T21:49:32.098678+00:00 app[web.1]: 
2013-05-10T21:49:32.098678+00:00 app[web.1]: ActiveRecord::StatementInvalid (PG::Error: ERROR:  function rand() does not exist
2013-05-10T21:49:32.098678+00:00 app[web.1]: LINE 1: SELECT  "sammiches".* FROM "sammiches"  ORDER BY RAND() LIMI...
2013-05-10T21:49:32.098678+00:00 app[web.1]:   app/controllers/sammiches_controller.rb:9:in `random'
2013-05-10T21:49:32.098678+00:00 app[web.1]:                                                          ^
2013-05-10T21:49:32.098678+00:00 app[web.1]: : SELECT  "sammiches".* FROM "sammiches"  ORDER BY RAND() LIMIT 1):
2013-05-10T21:49:32.098678+00:00 app[web.1]: HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
2013-05-10T21:49:32.098678+00:00 app[web.1]: 
2013-05-10T21:49:32.098678+00:00 app[web.1]: 
2013-05-10T22:02:12.538140+00:00 heroku[router]: at=info method=GET path=/ host=powerful-plateau-7517.herokuapp.com fwd="98.210.56.231" dyno=web.1 connect=12ms service=18ms status=304 bytes=0
2013-05-10T22:02:12.680175+00:00 heroku[router]: at=info method=GET path=/assets/application-9d330e31ec44ccdd3433e817066e781f.js host=powerful-plateau-7517.herokuapp.com fwd="98.210.56.231" dyno=web.1 connect=1ms service=4ms status=304 bytes=0
2013-05-10T22:02:13.269519+00:00 heroku[router]: at=info method=GET path=/favicon.ico host=powerful-plateau-7517.herokuapp.com fwd="98.210.56.231" dyno=web.1 connect=10ms service=387ms status=304 bytes=0
2013-05-10T22:02:12.524771+00:00 app[web.1]: Started GET "/" for 98.210.56.231 at 2013-05-10 22:02:12 +0000
2013-05-10T22:02:12.528043+00:00 app[web.1]: Processing by SammichesController#index as HTML
2013-05-10T22:02:12.532935+00:00 app[web.1]:   Rendered sammiches/index.html.erb within layouts/application (1.5ms)
2013-05-10T22:02:12.533794+00:00 app[web.1]: Completed 200 OK in 6ms (Views: 2.8ms | ActiveRecord: 2.4ms)
2013-05-10T22:02:16.380795+00:00 heroku[router]: at=info method=POST path=/sammiches host=powerful-plateau-7517.herokuapp.com fwd="98.210.56.231" dyno=web.1 connect=1ms service=71ms status=200 bytes=555
2013-05-10T22:02:16.322944+00:00 app[web.1]: Started POST "/sammiches" for 98.210.56.231 at 2013-05-10 22:02:16 +0000
2013-05-10T22:02:16.325519+00:00 app[web.1]: Processing by SammichesController#create as HTML
2013-05-10T22:02:16.375837+00:00 app[web.1]:   Rendered sammiches/create.html.erb within layouts/application (0.4ms)
2013-05-10T22:02:16.326153+00:00 app[web.1]:   Parameters: {"utf8"=>"✓", "authenticity_token"=>"k66KN4jnDL18AmnRcbDXp2N+ne13+TDz3MFBbyzqN2k=", "sammich"=>{"name"=>"bacon"}, "commit"=>"Find Sammich"}
2013-05-10T22:02:16.376839+00:00 app[web.1]: Completed 200 OK in 51ms (Views: 2.1ms | ActiveRecord: 3.6ms)
2013-05-10T22:02:18.774467+00:00 heroku[router]: at=info method=GET path=/sammiches/random host=powerful-plateau-7517.herokuapp.com fwd="98.210.56.231" dyno=web.1 connect=1ms service=13ms status=500 bytes=643
2013-05-10T22:02:18.771226+00:00 app[web.1]: Processing by SammichesController#random as HTML
2013-05-10T22:02:18.774242+00:00 app[web.1]: Completed 500 Internal Server Error in 3ms
2013-05-10T22:02:18.775344+00:00 app[web.1]: 
2013-05-10T22:02:18.775344+00:00 app[web.1]: ActiveRecord::StatementInvalid (PG::Error: ERROR:  function rand() does not exist
2013-05-10T22:02:18.768260+00:00 app[web.1]: Started GET "/sammiches/random" for 98.210.56.231 at 2013-05-10 22:02:18 +0000
2013-05-10T22:02:18.775344+00:00 app[web.1]: 
2013-05-10T22:02:18.775344+00:00 app[web.1]: HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
2013-05-10T22:02:18.775344+00:00 app[web.1]:                                                          ^
2013-05-10T22:02:18.775344+00:00 app[web.1]: : SELECT  "sammiches".* FROM "sammiches"  ORDER BY RAND() LIMIT 1):
2013-05-10T22:02:18.775344+00:00 app[web.1]:   app/controllers/sammiches_controller.rb:9:in `random'
2013-05-10T22:02:18.775344+00:00 app[web.1]: LINE 1: SELECT  "sammiches".* FROM "sammiches"  ORDER BY RAND() LIMI...
2013-05-10T22:02:18.775344+00:00 app[web.1]: 
2013-05-10T23:04:56.020256+00:00 heroku[web.1]: Idling
2013-05-10T23:04:58.934834+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2013-05-10T23:04:59.639390+00:00 app[web.1]: [2013-05-10 23:04:59] ERROR SignalException: SIGTERM
2013-05-10T23:04:59.639390+00:00 app[web.1]:    /usr/local/lib/ruby/1.9.1/webrick/server.rb:90:in `select'
2013-05-10T23:05:09.120630+00:00 heroku[web.1]: Stopping remaining processes with SIGKILL
2013-05-10T23:05:09.120478+00:00 heroku[web.1]: Error R12 (Exit timeout) -> At least one process failed to exit within 10 seconds of SIGTERM
2013-05-10T23:05:10.990155+00:00 heroku[web.1]: Process exited with status 137
2013-05-10T23:05:10.998635+00:00 heroku[web.1]: State changed from up to down
2013-05-10T23:28:01.280620+00:00 heroku[web.1]: Unidling
2013-05-10T23:28:01.282835+00:00 heroku[web.1]: State changed from down to starting
2013-05-10T23:28:02.521689+00:00 heroku[web.1]: Starting process with command `bundle exec rails server -p 9222`
2013-05-10T23:28:08.672954+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-05-10T23:28:08.673560+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-05-10T23:28:11.291390+00:00 app[web.1]: Connecting to database specified by DATABASE_URL
2013-05-10T23:28:11.291390+00:00 app[web.1]: => Rails 3.2.13 application starting in production on http://0.0.0.0:9222
2013-05-10T23:28:11.291390+00:00 app[web.1]: => Booting WEBrick
2013-05-10T23:28:11.291390+00:00 app[web.1]: => Call with -d to detach
2013-05-10T23:28:11.291390+00:00 app[web.1]: => Ctrl-C to shutdown server
2013-05-10T23:28:11.444640+00:00 app[web.1]: [2013-05-10 23:28:11] INFO  WEBrick 1.3.1
2013-05-10T23:28:11.444640+00:00 app[web.1]: [2013-05-10 23:28:11] INFO  ruby 1.9.2 (2011-07-09) [x86_64-linux]
2013-05-10T23:28:11.445062+00:00 app[web.1]: [2013-05-10 23:28:11] INFO  WEBrick::HTTPServer#start: pid=2 port=9222
2013-05-10T23:28:11.691997+00:00 heroku[web.1]: State changed from starting to up
2013-05-10T23:28:13.489565+00:00 app[web.1]: Started GET "/" for 98.210.56.231 at 2013-05-10 23:28:13 +0000
2013-05-10T23:28:14.038525+00:00 app[web.1]: Processing by SammichesController#index as HTML
2013-05-10T23:28:14.452552+00:00 app[web.1]:   Rendered sammiches/index.html.erb within layouts/application (11.3ms)
2013-05-10T23:28:14.454810+00:00 app[web.1]: Completed 200 OK in 411ms (Views: 61.7ms | ActiveRecord: 190.8ms)
2013-05-10T23:28:14.463099+00:00 heroku[router]: at=info method=GET path=/ host=powerful-plateau-7517.herokuapp.com fwd="98.210.56.231" dyno=web.1 connect=10ms service=1016ms status=304 bytes=0
2013-05-10T23:28:14.860856+00:00 heroku[router]: at=info method=GET path=/assets/application-1b13569e9620782f423d4cd3ce931750.css host=powerful-plateau-7517.herokuapp.com fwd="98.210.56.231" dyno=web.1 connect=5ms service=14ms status=304 bytes=0
2013-05-10T23:28:14.936859+00:00 heroku[router]: at=info method=GET path=/assets/application-9d330e31ec44ccdd3433e817066e781f.js host=powerful-plateau-7517.herokuapp.com fwd="98.210.56.231" dyno=web.1 connect=2ms service=18ms status=304 bytes=0
2013-05-10T23:28:15.119283+00:00 heroku[router]: at=info method=GET path=/favicon.ico host=powerful-plateau-7517.herokuapp.com fwd="98.210.56.231" dyno=web.1 connect=3ms service=10ms status=304 bytes=0
2013-05-10T23:28:17.830955+00:00 app[web.1]: Started GET "/sammiches/random" for 98.210.56.231 at 2013-05-10 23:28:17 +0000
2013-05-10T23:28:17.846392+00:00 app[web.1]: Processing by SammichesController#random as HTML
2013-05-10T23:28:17.885944+00:00 app[web.1]: LINE 1: SELECT  "sammiches".* FROM "sammiches"  ORDER BY RAND() LIMI...
2013-05-10T23:28:17.884527+00:00 app[web.1]: Completed 500 Internal Server Error in 38ms
2013-05-10T23:28:17.885944+00:00 app[web.1]: ActiveRecord::StatementInvalid (PG::Error: ERROR:  function rand() does not exist
2013-05-10T23:28:17.885944+00:00 app[web.1]:   app/controllers/sammiches_controller.rb:9:in `random'
2013-05-10T23:28:17.885944+00:00 app[web.1]: 
2013-05-10T23:28:17.885944+00:00 app[web.1]: HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
2013-05-10T23:28:17.885944+00:00 app[web.1]:                                                          ^
2013-05-10T23:28:17.885944+00:00 app[web.1]: 
2013-05-10T23:28:17.885944+00:00 app[web.1]: : SELECT  "sammiches".* FROM "sammiches"  ORDER BY RAND() LIMIT 1):
2013-05-10T23:28:17.898362+00:00 heroku[router]: at=info method=GET path=/sammiches/random host=powerful-plateau-7517.herokuapp.com fwd="98.210.56.231" dyno=web.1 connect=2ms service=61ms status=500 bytes=643
2013-05-10T23:28:17.885944+00:00 app[web.1]: 

将不胜感激任何帮助。谢谢!

4

1 回答 1

3

您的 sql 语句不是 postgres 语句:

ActiveRecord::StatementInvalid (PG::Error: ERROR:  function rand() does not exist

rand()是一个mysql函数。等效的 pg one 称为random().

于 2013-05-10T23:35:46.613 回答