Note that there are some explanatory texts on larger screens.

plurals
  1. POIssue with running a migration on heroku
    primarykey
    data
    text
    <p>This is a follow up to this post <a href="https://stackoverflow.com/questions/7482975/rails-data-structure-and-performance">Rails, data structure and performance</a>, where I have attempted to create a Counter Cache on Rails. To not have it to default 0, I have also added updating the column to the existing count value in the database.</p> <p>Running rake db:migrate on development works fine, even though it took a few hours to run.</p> <p>But running the migration with heroku is giving me the following error : </p> <pre><code>== AddVotesCount: migrating ================================================== -- add_column(:options, :votes_count, :integer, {:default=&gt;0}) -&gt; 0.0196s /Users/ebellity/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/net/http.rb:644:in `initialize': Operation timed out - connect(2) (Errno::ETIMEDOUT) from /Users/ebellity/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/net/http.rb:644:in `open' from /Users/ebellity/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/net/http.rb:644:in `block in connect' from /Users/ebellity/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/timeout.rb:44:in `timeout' from /Users/ebellity/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/timeout.rb:87:in `timeout' from /Users/ebellity/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/net/http.rb:644:in `connect' from /Users/ebellity/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/net/http.rb:637:in `do_start' from /Users/ebellity/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/net/http.rb:626:in `start' from /Users/ebellity/.rvm/gems/ruby-1.9.2-p136/gems/rest-client-1.6.7/lib/restclient/request.rb:172:in `transmit' from /Users/ebellity/.rvm/gems/ruby-1.9.2-p136/gems/rest-client-1.6.7/lib/restclient/request.rb:64:in `execute' from /Users/ebellity/.rvm/gems/ruby-1.9.2-p136/gems/rest-client-1.6.7/lib/restclient/request.rb:33:in `execute' from /Users/ebellity/.rvm/gems/ruby-1.9.2-p136/gems/rest-client-1.6.7/lib/restclient/resource.rb:51:in `get' from /Users/ebellity/.rvm/gems/ruby-1.9.2-p136/gems/heroku-2.8.4/lib/heroku/client.rb:554:in `process' from /Users/ebellity/.rvm/gems/ruby-1.9.2-p136/gems/heroku-2.8.4/lib/heroku/client.rb:532:in `get' from /Users/ebellity/.rvm/gems/ruby-1.9.2-p136/gems/heroku-2.8.4/lib/heroku/client.rb:290:in `read' from /Users/ebellity/.rvm/gems/ruby-1.9.2-p136/gems/heroku-2.8.4/lib/heroku/client.rb:311:in `each' from /Users/ebellity/.rvm/gems/ruby-1.9.2-p136/gems/heroku-2.8.4/lib/heroku/command/run.rb:50:in `rake' from /Users/ebellity/.rvm/gems/ruby-1.9.2-p136/gems/heroku-2.8.4/lib/heroku/command.rb:114:in `run' from /Users/ebellity/.rvm/gems/ruby-1.9.2-p136/gems/heroku-2.8.4/bin/heroku:14:in `&lt;top (required)&gt;' from /Users/ebellity/.rvm/gems/ruby-1.9.2-p136/bin/heroku:19:in `load' from /Users/ebellity/.rvm/gems/ruby-1.9.2-p136/bin/heroku:19:in `&lt;main&gt;' </code></pre> <p>I have tried a few different things but seem lost at this point, any help appreciated ! The strange thing is that the error message does not always come up instantly, sometimes it takes 10/20 minutes as if the migration was running.</p> <p>Thanks</p> <p>Update : here is the content of my migration file :</p> <pre><code>class AddVotesCount &lt; ActiveRecord::Migration def self.up add_column :options, :votes_count, :integer, :default =&gt; 0 Option.all.each do |option| option.votes_count = option.votes.count option.save! end end def self.down remove_column :options, :votes_count end end </code></pre> <p>Update 2 : This works in staging environment with heroku... but not in production</p> <p>After a few modifications, the migration code is now :</p> <pre><code>def self.up add_column :options, :votes_count, :integer, :default =&gt; 0 Option.reset_column_information Option.find_each do |option| Option.reset_counters option.id, :votes end </code></pre> <p>and the error is :</p> <pre><code>== AddVotesCount: migrating ================================================== -- add_column(:options, :votes_count, :integer, {:default=&gt;0}) -&gt; 0.0224s /Users/ebellity/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/net/http.rb:644:in `initialize': getaddrinfo: nodename nor servname provided, or not known (SocketError) from /Users/ebellity/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/net/http.rb:644:in `open' from /Users/ebellity/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/net/http.rb:644:in `block in connect' from /Users/ebellity/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/timeout.rb:44:in `timeout' from /Users/ebellity/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/timeout.rb:87:in `timeout' from /Users/ebellity/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/net/http.rb:644:in `connect' from /Users/ebellity/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/net/http.rb:637:in `do_start' from /Users/ebellity/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/net/http.rb:626:in `start' from /Users/ebellity/.rvm/gems/ruby-1.9.2-p136/gems/rest-client-1.6.7/lib/restclient/request.rb:172:in `transmit' from /Users/ebellity/.rvm/gems/ruby-1.9.2-p136/gems/rest-client-1.6.7/lib/restclient/request.rb:64:in `execute' from /Users/ebellity/.rvm/gems/ruby-1.9.2-p136/gems/rest-client-1.6.7/lib/restclient/request.rb:33:in `execute' from /Users/ebellity/.rvm/gems/ruby-1.9.2-p136/gems/rest-client-1.6.7/lib/restclient/resource.rb:51:in `get' from /Users/ebellity/.rvm/gems/ruby-1.9.2-p136/gems/heroku-2.8.4/lib/heroku/client.rb:554:in `process' from /Users/ebellity/.rvm/gems/ruby-1.9.2-p136/gems/heroku-2.8.4/lib/heroku/client.rb:532:in `get' from /Users/ebellity/.rvm/gems/ruby-1.9.2-p136/gems/heroku-2.8.4/lib/heroku/client.rb:290:in `read' from /Users/ebellity/.rvm/gems/ruby-1.9.2-p136/gems/heroku-2.8.4/lib/heroku/client.rb:311:in `each' from /Users/ebellity/.rvm/gems/ruby-1.9.2-p136/gems/heroku-2.8.4/lib/heroku/command/run.rb:50:in `rake' from /Users/ebellity/.rvm/gems/ruby-1.9.2-p136/gems/heroku-2.8.4/lib/heroku/command.rb:114:in `run' from /Users/ebellity/.rvm/gems/ruby-1.9.2-p136/gems/heroku-2.8.4/bin/heroku:14:in `&lt;top (required)&gt;' from /Users/ebellity/.rvm/gems/ruby-1.9.2-p136/bin/heroku:19:in `load' from /Users/ebellity/.rvm/gems/ruby-1.9.2-p136/bin/heroku:19:in `&lt;main&gt;' </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload