{"action":"created","issue":{"url":"https://api.github.com/repos/rails/rails/issues/21670","labels_url":"https://api.github.com/repos/rails/rails/issues/21670/labels{/name}","comments_url":"https://api.github.com/repos/rails/rails/issues/21670/comments","events_url":"https://api.github.com/repos/rails/rails/issues/21670/events","html_url":"https://github.com/rails/rails/pull/21670","id":107280867,"number":21670,"title":"Add created_at to schema_migrations and some code cleanup","user":{"login":"keithgabryelski","id":884378,"avatar_url":"https://avatars.githubusercontent.com/u/884378?v=3","gravatar_id":"","url":"https://api.github.com/users/keithgabryelski","html_url":"https://github.com/keithgabryelski","followers_url":"https://api.github.com/users/keithgabryelski/followers","following_url":"https://api.github.com/users/keithgabryelski/following{/other_user}","gists_url":"https://api.github.com/users/keithgabryelski/gists{/gist_id}","starred_url":"https://api.github.com/users/keithgabryelski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keithgabryelski/subscriptions","organizations_url":"https://api.github.com/users/keithgabryelski/orgs","repos_url":"https://api.github.com/users/keithgabryelski/repos","events_url":"https://api.github.com/users/keithgabryelski/events{/privacy}","received_events_url":"https://api.github.com/users/keithgabryelski/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"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},"milestone":null,"comments":3,"created_at":"2015-09-18T21:22:51Z","updated_at":"2015-09-22T18:33:37Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/rails/rails/pulls/21670","html_url":"https://github.com/rails/rails/pull/21670","diff_url":"https://github.com/rails/rails/pull/21670.diff","patch_url":"https://github.com/rails/rails/pull/21670.patch"},"body":"*   Schema Migrations now contain time of creation information to track when\r\n    migrations were run.\r\n    ```\r\n\t  database: vagrant_development\r\n\r\n\t  Status   Migration ID    Migration Run             Migration Name\r\n\t  ---------------------------------------------------------------------------\r\n\t  up       20150918171109  2015-09-18 17:20:22 UTC   ********** NO FILE **********\r\n\t  up       20150918210543  2015-09-18 21:07:10 UTC   Bar\r\n\t  down     20150918210806                            Baz\r\n    ```\r\n"},"comment":{"url":"https://api.github.com/repos/rails/rails/issues/comments/142375593","html_url":"https://github.com/rails/rails/pull/21670#issuecomment-142375593","issue_url":"https://api.github.com/repos/rails/rails/issues/21670","id":142375593,"user":{"login":"keithgabryelski","id":884378,"avatar_url":"https://avatars.githubusercontent.com/u/884378?v=3","gravatar_id":"","url":"https://api.github.com/users/keithgabryelski","html_url":"https://github.com/keithgabryelski","followers_url":"https://api.github.com/users/keithgabryelski/followers","following_url":"https://api.github.com/users/keithgabryelski/following{/other_user}","gists_url":"https://api.github.com/users/keithgabryelski/gists{/gist_id}","starred_url":"https://api.github.com/users/keithgabryelski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keithgabryelski/subscriptions","organizations_url":"https://api.github.com/users/keithgabryelski/orgs","repos_url":"https://api.github.com/users/keithgabryelski/repos","events_url":"https://api.github.com/users/keithgabryelski/events{/privacy}","received_events_url":"https://api.github.com/users/keithgabryelski/received_events","type":"User","site_admin":false},"created_at":"2015-09-22T18:33:36Z","updated_at":"2015-09-22T18:33:36Z","body":"In some respects, this pull request is simply a formalization of this migration into ActiveRecord::SchemaMigration model/table:\r\n```ruby\r\nclass SchemaMigrationsTableGetsCreatedAt < ActiveRecord::Migration\r\n  def up\r\n    add_column :schema_migrations, :created_at, :datetime\r\n    ActiveRecord::SchemaMigration.where(created_at: nil).update_all('created_at = now()')\r\n    ActiveRecord::SchemaMigration.reset_column_information\r\n    change_column :schema_migrations, :created_at, :datetime, null: false\r\n  end\r\n\r\n  def down\r\n    remove_column :schema_migrations, :created_at\r\n  end\r\nend\r\n```\r\nexcept, again, it fixes the tests and cleans up the code to ActiveRecord::SchemaMigration instead of the the hard-coded SQL.\r\n"}}