Search code examples
ruby-on-railspostgresqlherokutapsheroku-toolbelt

heroku:db push is not working, time zone displacement out of range


I cannot seem to push using heroku, heroku db:pull works fine but not heroku db:push

here is the error i get

Taps Server Error: PGError: ERROR: time zone displacement out of range

my gemfile

source 'https://rubygems.org'

gem 'rails', '3.2.11'
gem 'jquery-rails'
gem 'kaminari'
gem 'bootstrap-kaminari-views'

gem 'devise'

gem 'pg'

gem 'rmagick'
gem 'carrierwave'
gem 'fog', '~> 1.3.1'

group :development do
  gem 'taps'
  gem 'sequel'
  gem 'sqlite3'
  gem 'pry'
end

group :assets do
  gem 'bootstrap-sass', '~> 2.2.1.1'
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'
  gem 'uglifier', '>= 1.0.3'
end

I am using ruby-1.9.3-p327, I have also tried installing ruby-1.9.2-p318 using rvm but it does not work either, it has the same time zone error as before


I have also tried using heroku's pgbackups to dump my local database upload it to s3 and then restore from there to heroku, but to no avail.


The commands i have used for pgbackups are

PGPASSWORD=mypassword pg_dump -Fc --no-acl --no-owner -h localhost -U myuser mydb > mydb.dump

Then i copied it to my s3 bucket and made it public

And restored it from s3 to heroku db using

heroku pgbackups:restore DATABASE 'https://s3.amazonaws.com/my_bucket/my_db.dump'

here is the error from pgbackups

2013-01-23T19:19:23+00:00 app[pgbackups]: psql: bin//psql-9.2.1-64bit
2013-01-23T19:19:23+00:00 app[pgbackups]: pv: bin//pv-1.1.4-64bit
2013-01-23T19:19:23+00:00 app[pgbackups]:       SELECT count(*) = 0 as is_empty
2013-01-23T19:19:23+00:00 app[pgbackups]:       FROM pg_class INNER JOIN pg_roles ON relowner = pg_roles.oid
2013-01-23T19:19:23+00:00 app[pgbackups]:       WHERE rolname <> '\''postgres'\'''
2013-01-23T19:19:44+00:00 app[pgbackups]: psql-9.2.1-64bit: could not connect to server: Connection timed out

Solution

  • It now works using ruby-1.9.2-p318 after removing heroku-toolbelt

    Here is what I did (Ubuntu 12.04)


    1. Remove heroku toolbelt

    sudo rm -rf /usr/local/heroku
    sudo rm -rf /usr/bin/heroku
    

    2. Update gemfile

    I added require false to taps

    group :development do
      gem 'taps', :require => false
    end
    

    and also add the heroku gem if you dont have it in your gemfile already

    gem 'heroku'
    

    3. Install ruby 1.9.2 and gems

    Navigate to your app (cd ~/sites/myapp) and do

    rvm install ruby-1.9.2-p318
    rvm use ruby-1.9.2-p318
    bundle install
    gem install rb-readline
    

    You should now have the heroku gem installed

    To double check run this in console
    ls ~/.rvm/gems/ruby-1.9.2-p318/gems
    You should now see a folder called heroku with a version appended to it. eg. heroku-2.26.3


    4. Run that push again

    Now you should still be in your app folder eg (~/sites/myapp)

    Try the push using the heroku gem you have just installed, remember to change your version if you have downloaded a diffirent one.

    ~/.rvm/gems/ruby-1.9.2-p318/gems/heroku-2.26.3/bin/heroku db:push
    

    it seems you need to switch back to ruby 1.9.3 to use rake db:migrate ect

    error i got when using rake db:migrate

    You're running a version of ruby with no Readline support
    Please `gem install rb-readline` or recompile ruby --with-readline.
    


    rvm use ruby-1.9.3-p327
    


    and you should be on your way!