{"action":"created","issue":{"url":"https://api.github.com/repos/rails/rails/issues/16919","labels_url":"https://api.github.com/repos/rails/rails/issues/16919/labels{/name}","comments_url":"https://api.github.com/repos/rails/rails/issues/16919/comments","events_url":"https://api.github.com/repos/rails/rails/issues/16919/events","html_url":"https://github.com/rails/rails/pull/16919","id":42730024,"number":16919,"title":"PostgreSQL interval datatype support","user":{"login":"Envek","id":264400,"avatar_url":"https://avatars.githubusercontent.com/u/264400?v=3","gravatar_id":"","url":"https://api.github.com/users/Envek","html_url":"https://github.com/Envek","followers_url":"https://api.github.com/users/Envek/followers","following_url":"https://api.github.com/users/Envek/following{/other_user}","gists_url":"https://api.github.com/users/Envek/gists{/gist_id}","starred_url":"https://api.github.com/users/Envek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Envek/subscriptions","organizations_url":"https://api.github.com/users/Envek/orgs","repos_url":"https://api.github.com/users/Envek/repos","events_url":"https://api.github.com/users/Envek/events{/privacy}","received_events_url":"https://api.github.com/users/Envek/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rails/rails/labels/activerecord","name":"activerecord","color":"0b02e1"}],"state":"open","locked":false,"assignee":{"login":"sgrif","id":1529387,"avatar_url":"https://avatars.githubusercontent.com/u/1529387?v=3","gravatar_id":"","url":"https://api.github.com/users/sgrif","html_url":"https://github.com/sgrif","followers_url":"https://api.github.com/users/sgrif/followers","following_url":"https://api.github.com/users/sgrif/following{/other_user}","gists_url":"https://api.github.com/users/sgrif/gists{/gist_id}","starred_url":"https://api.github.com/users/sgrif/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sgrif/subscriptions","organizations_url":"https://api.github.com/users/sgrif/orgs","repos_url":"https://api.github.com/users/sgrif/repos","events_url":"https://api.github.com/users/sgrif/events{/privacy}","received_events_url":"https://api.github.com/users/sgrif/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/rails/rails/milestones/34","html_url":"https://github.com/rails/rails/milestones/5.0.0","labels_url":"https://api.github.com/repos/rails/rails/milestones/34/labels","id":665192,"number":34,"title":"5.0.0","description":null,"creator":{"login":"rafaelfranca","id":47848,"avatar_url":"https://avatars.githubusercontent.com/u/47848?v=3","gravatar_id":"","url":"https://api.github.com/users/rafaelfranca","html_url":"https://github.com/rafaelfranca","followers_url":"https://api.github.com/users/rafaelfranca/followers","following_url":"https://api.github.com/users/rafaelfranca/following{/other_user}","gists_url":"https://api.github.com/users/rafaelfranca/gists{/gist_id}","starred_url":"https://api.github.com/users/rafaelfranca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rafaelfranca/subscriptions","organizations_url":"https://api.github.com/users/rafaelfranca/orgs","repos_url":"https://api.github.com/users/rafaelfranca/repos","events_url":"https://api.github.com/users/rafaelfranca/events{/privacy}","received_events_url":"https://api.github.com/users/rafaelfranca/received_events","type":"User","site_admin":false},"open_issues":82,"closed_issues":161,"state":"open","created_at":"2014-05-21T00:58:22Z","updated_at":"2015-11-01T09:01:49Z","due_on":null,"closed_at":null},"comments":14,"created_at":"2014-09-14T20:49:53Z","updated_at":"2015-11-03T08:18:44Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/rails/rails/pulls/16919","html_url":"https://github.com/rails/rails/pull/16919","diff_url":"https://github.com/rails/rails/pull/16919.diff","patch_url":"https://github.com/rails/rails/pull/16919.patch"},"body":"Add native support for PostgreSQL `interval` datatype with conversion from all PostgreSQL formats to `ActiveSupport::Duration` on record load and transformation from `ActiveSupport::Duration` to ISO 8601 on save (no more strings). Also added support to define column in migrations and get it in schema dump, optional column precision is supported.\r\n\r\n - Parses ISO 8601 duration format, tells Postgres to use it (see [Output formats])\r\n - Constructs `ActiveSupport::Duration` value (that magic `2.days`)\r\n - Converts `ActiveSupport::Duration` to [ISO 8601 duration] format on save\r\n - Allows to use old raw values on save — just pass the string in attribute writer\r\n - Allows to use `Numeric` values, treating them as number of seconds\r\n\r\nExample:\r\n\r\n    create_table :events do |t|\r\n      t.string   :name\r\n      t.interval :duration\r\n    end\r\n\r\n    Event.create!(name: 'Rock Fest', duration: 2.days)\r\n    Event.last.duration # => 2 days\r\n    Event.last.duration.iso8601 # => \"P2D\"\r\n\r\n    Event.create!(duration: '2 mons 1 day') # Raw values still works\r\n\r\nI've proposed this in Rails-core Google Group here: https://groups.google.com/forum/#!topic/rubyonrails-core/zcscu1p4ucA\r\n\r\n**ATTENTION**: This PR is built on top of #16917 and require it to be merged first. As it's not merged for now, commits and changes from it appears here, sorry for that hurry — I just want it to be included in upcoming 4.2 release, if it still possible (pleeeaase!). As #16917 will be progressed, I will rebase this branch on top of it (or anything else, what core team will say).\r\n\r\n[ISO 8601 duration]: http://en.wikipedia.org/wiki/ISO_8601#Durations\r\n[Output formats]: http://www.postgresql.org/docs/9.4/static/datatype-datetime.html#DATATYPE-INTERVAL-OUTPUT"},"comment":{"url":"https://api.github.com/repos/rails/rails/issues/comments/153285253","html_url":"https://github.com/rails/rails/pull/16919#issuecomment-153285253","issue_url":"https://api.github.com/repos/rails/rails/issues/16919","id":153285253,"user":{"login":"ollym","id":143771,"avatar_url":"https://avatars.githubusercontent.com/u/143771?v=3","gravatar_id":"","url":"https://api.github.com/users/ollym","html_url":"https://github.com/ollym","followers_url":"https://api.github.com/users/ollym/followers","following_url":"https://api.github.com/users/ollym/following{/other_user}","gists_url":"https://api.github.com/users/ollym/gists{/gist_id}","starred_url":"https://api.github.com/users/ollym/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ollym/subscriptions","organizations_url":"https://api.github.com/users/ollym/orgs","repos_url":"https://api.github.com/users/ollym/repos","events_url":"https://api.github.com/users/ollym/events{/privacy}","received_events_url":"https://api.github.com/users/ollym/received_events","type":"User","site_admin":false},"created_at":"2015-11-03T08:18:44Z","updated_at":"2015-11-03T08:18:44Z","body":"This is really important for me too, have a load of hacks in our code base that's keeping this together."}}