ruby on rails - Heroku Postgresql SET datestyle To european -


i addressing issue cannot copy data postgresql in rails because date format not in matching default postgresql iso mdy.

on local machine changed datestyle european dmy data matches correctly.

as usual, not easy on heroku production server. using steps below try change datestyle, works, doesn't persist (as shown exiting, going in , asking postgres show me datestyle).

any ideas how can persist this. research has show not , change code convert data mdy pulling millions of rows legacy system defaults dmy , using postgresql copy command fastest way possible. seems easier tell postgresql change datestyle fix else :/

$ heroku pg:psql     app-name::crimson=> set datestyle 'european'; set app-name::crimson=> show datestyle;  datestyle  -----------  iso, dmy (1 row)  app-name::crimson-> \q $ heroku pg:psql ---> connecting heroku_postgresql_crimson_url (database_url) psql (9.4.1, server 9.3.6) ssl connection (protocol: tlsv1.2, cipher: jibberish, bits: 256, compression: off) type "help" help.  app-name::crimson=> show datestyle;  datestyle  -----------  iso, mdy (1 row) 

any ideas how can persist this.

datestyle server setting (in postgresql.conf) client sessions can override (with set datestyle ...) single transaction or single session. there 2 ways persist change beyond single session.

  • change setting in postgresql.conf , restart server. (won't work on heroku. surely don't have privileges edit postgresql.conf, right?)
  • alter database your_database_name set datestyle 'iso, european'; (should work on heroku. i'd set stand-alone migration.)

fwiw, default isn't iso mdy, it's iso, mdy. (two values, separated comma.) first "output format specification"; second "input/output specification year/month/day ordering". (see client connection defaults)


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -