Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error when pushing data to Heroku: time zone displacement out of range

I run the following command to push the contents of my local database to Heroku:

heroku db:push --app my-app

From my home computer this works flawlessly but from my work computer I get this error:

Taps Server Error: PGError: ERROR: time zone displacement out of range: "2011-11-15 12:00:00.000000+5894114400"

I'm not sure where that date is coming from, I can't find it in the data anywhere. Any ideas what's going on and/or how to fix it?

like image 404
pupeno Avatar asked Nov 16 '11 12:11

pupeno


4 Answers

Using Ruby 1.9.2-p290 instead of 1.9.3-p0 fixed it for me. According to Roger Braun, this is the reason:

The problem is (I think), that marshalling changed between Ruby 1.9.2 and 1.9.3, so this is not really a taps error. Just use whatever version heroku runs to push and pull databases (Probably 1.9.2).

like image 146
pupeno Avatar answered Nov 19 '22 23:11

pupeno


Downgrading to Ruby 1.9.2 from Ruby 1.9.3 does not sound like an appealing option to me.

Heroku's devcentre page actually suggests using pgbackups addon to managing databases ( https://devcenter.heroku.com/articles/pgbackups) . It may sound like it's only for taking backups of production databases down to your local machine but if you read it carefully, they have a large section which deals with "importing a database". What they suggest is that you upload your database to a publically accessible location and run the suggested command

heroku pgbackups:restore DATABASE 'http://s3.amazonaws.com/.....mydb.dump?authparameters'

So, in effect they provide commands to dump your local database, suggest ways to upload it to a location that heroku's servers can fetch your database dump from (assuming your local development machine is not publically accessible from the internet) and then the above command for it to be uploaded into production environment on heroku.

Just putting this up here, since i think problem has been persisting for a very long time without adequate resolution on the real problem.

like image 44
Aditya Sanghi Avatar answered Nov 20 '22 00:11

Aditya Sanghi


I run 1.9.3p125 on Heroku and 1.9.3p125 on my local machine. If I want to db:push I just switch to 1.9.2 while uploading:

rvm use ruby-1.9.2-p290
heroku db:push --app my-app
rvm use ruby-1.9.3-p125

Then once the push is complete, I switch back to 1.9.3.

like image 8
Kevin Bedell Avatar answered Nov 19 '22 23:11

Kevin Bedell


It didn't work for me either using 1.9.3 or 1.9.2.

As Pablo pointed out the problem has to do with the marshalling of the dates (the marshalling converts the date to 12:00:00+XXXX" despite my date type was 'timestamp without timezone').

Anyway, I worked it around by setting the dates to null, so I could successfully push to Heroku. Very poor solution, though. I hope the bug will get fixed soon.

like image 4
Diego Pino Avatar answered Nov 19 '22 22:11

Diego Pino