PG::Datetimefieldoverflow: ERROR: date/time field value out of range: "22/11/2019 19:47:22.793483"

Asked

Viewed 1,279 times

1

I’m developing an application on Ror and moving it up to Heroku.

When I use the command heroku run rake db:migrate I get that mistake:

$ heroku run rake db:migrate
Running rake db:migrate on ⬢ evening-harbor-67551... up, run.2309 (Free)
D, [2019-11-22T19:47:22.752853 #4] DEBUG -- :    (1.3ms)  SELECT pg_try_advisory_lock(2815438446527332605)
D, [2019-11-22T19:47:22.770993 #4] DEBUG -- :    (1.7ms)  SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
D, [2019-11-22T19:47:22.782317 #4] DEBUG -- :   ActiveRecord::InternalMetadata Load (1.4ms)  SELECT  "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2  [["key", "environment"], ["LIMIT", 1]]
D, [2019-11-22T19:47:22.792704 #4] DEBUG -- :    (1.0ms)  BEGIN
D, [2019-11-22T19:47:22.796649 #4] DEBUG -- :   ActiveRecord::InternalMetadata Create (2.0ms)  INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key"  [["key", "environment"], ["value", "production"], ["created_at", "22/11/2019 19:47:22.793483"], ["updated_at", "22/11/2019 19:47:22.793483"]]
D, [2019-11-22T19:47:22.797942 #4] DEBUG -- :    (1.1ms)  ROLLBACK
D, [2019-11-22T19:47:22.799467 #4] DEBUG -- :    (1.2ms)  SELECT pg_advisory_unlock(2815438446527332605)
rake aborted!
ActiveRecord::StatementInvalid: PG::DatetimeFieldOverflow: ERROR:  date/time field value out of range: "22/11/2019 19:47:22.793483"
HINT:  Perhaps you need a different "datestyle" setting.
: INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key"

I tried to change datestyle to DMY and MDY and no option worked.

I have another application with the same version of ruby and Rails and works normally.

Does anyone have any idea how to fix this?

  • How did you change datestyle? No postgresql.conf or set? What shows the datestyle SHOW?

1 answer

0

My database did not accept dates with '/' In a file date_time_formats.Rb Voce can change control the return of Ror’s time methods. I just added the line

Time::DATE_FORMATS[:db]= '%Y-%m-%d %H:%M:%S'

Browser other questions tagged

You are not signed in. Login or sign up in order to post.