{"action":"created","comment":{"url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/pulls/comments/44541075","id":44541075,"diff_hunk":"@@ -0,0 +1,72 @@\n+class RemoveLatitudeAndLongitudeFromFirm < ActiveRecord::Migration\n+  class Firm < ActiveRecord::Base\n+    has_many :offices, -> { order created_at: :asc }\n+    scope :geocoded, -> { where.not(latitude: nil, longitude: nil) }\n+\n+    def main_office\n+      offices.first\n+    end\n+  end\n+\n+  class Office < ActiveRecord::Base\n+    belongs_to :firm\n+\n+    def geocoded?\n+      latitude.present? && longitude.present?\n+    end\n+  end\n+\n+  def up\n+    migrate_firm_coords_to_main_office\n+\n+    remove_column :firms, :latitude\n+    remove_column :firms, :longitude\n+\n+    index_warning\n+  end\n+\n+  def down\n+    add_column :firms, :latitude, :float\n+    add_column :firms, :longitude, :float\n+\n+    migrate_main_office_coords_to_firm\n+\n+    index_warning\n+  end\n+\n+  private\n+\n+  def migrate_firm_coords_to_main_office\n+    update_count = 0\n+\n+    Firm.geocoded.includes(:offices).find_each do |f|\n+      next unless f.offices.present?\n+\n+      f.main_office.update!(latitude: f.latitude,\n+                            longitude: f.longitude)\n+\n+      update_count += 1\n+    end\n+\n+    say \"Migrated #{update_count} coordinates to main offices\"","path":"db/migrate/20151111132037_remove_latitude_and_longitude_from_firm.rb","position":51,"original_position":51,"commit_id":"4edb32c810603ef25bdd0fbc3824738f7e859886","original_commit_id":"4edb32c810603ef25bdd0fbc3824738f7e859886","user":{"login":"munckymagik","id":306583,"avatar_url":"https://avatars.githubusercontent.com/u/306583?v=3","gravatar_id":"","url":"https://api.github.com/users/munckymagik","html_url":"https://github.com/munckymagik","followers_url":"https://api.github.com/users/munckymagik/followers","following_url":"https://api.github.com/users/munckymagik/following{/other_user}","gists_url":"https://api.github.com/users/munckymagik/gists{/gist_id}","starred_url":"https://api.github.com/users/munckymagik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/munckymagik/subscriptions","organizations_url":"https://api.github.com/users/munckymagik/orgs","repos_url":"https://api.github.com/users/munckymagik/repos","events_url":"https://api.github.com/users/munckymagik/events{/privacy}","received_events_url":"https://api.github.com/users/munckymagik/received_events","type":"User","site_admin":false},"body":"Oh! I see, LOL :)\r\n\r\nNo it's not [say](https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/say.1.html) it's [say](http://apidock.com/rails/ActiveRecord/Migration/say/class#211-print-standard-looking-messages-during-migration)\r\n\r\nWe're running migrations on heroku which mean we can see the output.\r\n","created_at":"2015-11-11T15:03:31Z","updated_at":"2015-11-11T15:03:31Z","html_url":"https://github.com/moneyadviceservice/mas-rad_core/pull/129#discussion_r44541075","pull_request_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/pulls/129","_links":{"self":{"href":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/pulls/comments/44541075"},"html":{"href":"https://github.com/moneyadviceservice/mas-rad_core/pull/129#discussion_r44541075"},"pull_request":{"href":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/pulls/129"}}},"pull_request":{"url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/pulls/129","id":50390718,"html_url":"https://github.com/moneyadviceservice/mas-rad_core/pull/129","diff_url":"https://github.com/moneyadviceservice/mas-rad_core/pull/129.diff","patch_url":"https://github.com/moneyadviceservice/mas-rad_core/pull/129.patch","issue_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/issues/129","number":129,"state":"open","locked":false,"title":"Stop geocoding firms and migrate existing geo data to main office records","user":{"login":"munckymagik","id":306583,"avatar_url":"https://avatars.githubusercontent.com/u/306583?v=3","gravatar_id":"","url":"https://api.github.com/users/munckymagik","html_url":"https://github.com/munckymagik","followers_url":"https://api.github.com/users/munckymagik/followers","following_url":"https://api.github.com/users/munckymagik/following{/other_user}","gists_url":"https://api.github.com/users/munckymagik/gists{/gist_id}","starred_url":"https://api.github.com/users/munckymagik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/munckymagik/subscriptions","organizations_url":"https://api.github.com/users/munckymagik/orgs","repos_url":"https://api.github.com/users/munckymagik/repos","events_url":"https://api.github.com/users/munckymagik/events{/privacy}","received_events_url":"https://api.github.com/users/munckymagik/received_events","type":"User","site_admin":false},"body":"This is a clean up PR to remove unused fields from firm and migrate data to offices.","created_at":"2015-11-11T14:47:28Z","updated_at":"2015-11-11T15:03:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"deafafa30dd5c731baea676674fd441e8789833f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/pulls/129/commits","review_comments_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/pulls/129/comments","review_comment_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/pulls/comments{/number}","comments_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/issues/129/comments","statuses_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/statuses/4edb32c810603ef25bdd0fbc3824738f7e859886","head":{"label":"moneyadviceservice:stop_geocoding_firms","ref":"stop_geocoding_firms","sha":"4edb32c810603ef25bdd0fbc3824738f7e859886","user":{"login":"moneyadviceservice","id":2064781,"avatar_url":"https://avatars.githubusercontent.com/u/2064781?v=3","gravatar_id":"","url":"https://api.github.com/users/moneyadviceservice","html_url":"https://github.com/moneyadviceservice","followers_url":"https://api.github.com/users/moneyadviceservice/followers","following_url":"https://api.github.com/users/moneyadviceservice/following{/other_user}","gists_url":"https://api.github.com/users/moneyadviceservice/gists{/gist_id}","starred_url":"https://api.github.com/users/moneyadviceservice/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/moneyadviceservice/subscriptions","organizations_url":"https://api.github.com/users/moneyadviceservice/orgs","repos_url":"https://api.github.com/users/moneyadviceservice/repos","events_url":"https://api.github.com/users/moneyadviceservice/events{/privacy}","received_events_url":"https://api.github.com/users/moneyadviceservice/received_events","type":"Organization","site_admin":false},"repo":{"id":30658923,"name":"mas-rad_core","full_name":"moneyadviceservice/mas-rad_core","owner":{"login":"moneyadviceservice","id":2064781,"avatar_url":"https://avatars.githubusercontent.com/u/2064781?v=3","gravatar_id":"","url":"https://api.github.com/users/moneyadviceservice","html_url":"https://github.com/moneyadviceservice","followers_url":"https://api.github.com/users/moneyadviceservice/followers","following_url":"https://api.github.com/users/moneyadviceservice/following{/other_user}","gists_url":"https://api.github.com/users/moneyadviceservice/gists{/gist_id}","starred_url":"https://api.github.com/users/moneyadviceservice/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/moneyadviceservice/subscriptions","organizations_url":"https://api.github.com/users/moneyadviceservice/orgs","repos_url":"https://api.github.com/users/moneyadviceservice/repos","events_url":"https://api.github.com/users/moneyadviceservice/events{/privacy}","received_events_url":"https://api.github.com/users/moneyadviceservice/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/moneyadviceservice/mas-rad_core","description":"Models and core logic engine for the RAD family of products and services","fork":false,"url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core","forks_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/forks","keys_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/teams","hooks_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/hooks","issue_events_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/issues/events{/number}","events_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/events","assignees_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/assignees{/user}","branches_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/branches{/branch}","tags_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/tags","blobs_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/git/refs{/sha}","trees_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/statuses/{sha}","languages_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/languages","stargazers_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/stargazers","contributors_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/contributors","subscribers_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/subscribers","subscription_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/subscription","commits_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/commits{/sha}","git_commits_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/git/commits{/sha}","comments_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/comments{/number}","issue_comment_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/issues/comments{/number}","contents_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/contents/{+path}","compare_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/merges","archive_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/downloads","issues_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/issues{/number}","pulls_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/pulls{/number}","milestones_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/milestones{/number}","notifications_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/labels{/name}","releases_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/releases{/id}","created_at":"2015-02-11T17:01:07Z","updated_at":"2015-06-15T15:36:55Z","pushed_at":"2015-11-11T14:47:28Z","git_url":"git://github.com/moneyadviceservice/mas-rad_core.git","ssh_url":"git@github.com:moneyadviceservice/mas-rad_core.git","clone_url":"https://github.com/moneyadviceservice/mas-rad_core.git","svn_url":"https://github.com/moneyadviceservice/mas-rad_core","homepage":null,"size":2047,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"moneyadviceservice:master","ref":"master","sha":"edeced0ff57d54179a44297ad9f99d841404a7a6","user":{"login":"moneyadviceservice","id":2064781,"avatar_url":"https://avatars.githubusercontent.com/u/2064781?v=3","gravatar_id":"","url":"https://api.github.com/users/moneyadviceservice","html_url":"https://github.com/moneyadviceservice","followers_url":"https://api.github.com/users/moneyadviceservice/followers","following_url":"https://api.github.com/users/moneyadviceservice/following{/other_user}","gists_url":"https://api.github.com/users/moneyadviceservice/gists{/gist_id}","starred_url":"https://api.github.com/users/moneyadviceservice/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/moneyadviceservice/subscriptions","organizations_url":"https://api.github.com/users/moneyadviceservice/orgs","repos_url":"https://api.github.com/users/moneyadviceservice/repos","events_url":"https://api.github.com/users/moneyadviceservice/events{/privacy}","received_events_url":"https://api.github.com/users/moneyadviceservice/received_events","type":"Organization","site_admin":false},"repo":{"id":30658923,"name":"mas-rad_core","full_name":"moneyadviceservice/mas-rad_core","owner":{"login":"moneyadviceservice","id":2064781,"avatar_url":"https://avatars.githubusercontent.com/u/2064781?v=3","gravatar_id":"","url":"https://api.github.com/users/moneyadviceservice","html_url":"https://github.com/moneyadviceservice","followers_url":"https://api.github.com/users/moneyadviceservice/followers","following_url":"https://api.github.com/users/moneyadviceservice/following{/other_user}","gists_url":"https://api.github.com/users/moneyadviceservice/gists{/gist_id}","starred_url":"https://api.github.com/users/moneyadviceservice/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/moneyadviceservice/subscriptions","organizations_url":"https://api.github.com/users/moneyadviceservice/orgs","repos_url":"https://api.github.com/users/moneyadviceservice/repos","events_url":"https://api.github.com/users/moneyadviceservice/events{/privacy}","received_events_url":"https://api.github.com/users/moneyadviceservice/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/moneyadviceservice/mas-rad_core","description":"Models and core logic engine for the RAD family of products and services","fork":false,"url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core","forks_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/forks","keys_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/teams","hooks_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/hooks","issue_events_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/issues/events{/number}","events_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/events","assignees_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/assignees{/user}","branches_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/branches{/branch}","tags_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/tags","blobs_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/git/refs{/sha}","trees_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/statuses/{sha}","languages_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/languages","stargazers_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/stargazers","contributors_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/contributors","subscribers_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/subscribers","subscription_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/subscription","commits_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/commits{/sha}","git_commits_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/git/commits{/sha}","comments_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/comments{/number}","issue_comment_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/issues/comments{/number}","contents_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/contents/{+path}","compare_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/merges","archive_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/downloads","issues_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/issues{/number}","pulls_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/pulls{/number}","milestones_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/milestones{/number}","notifications_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/labels{/name}","releases_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/releases{/id}","created_at":"2015-02-11T17:01:07Z","updated_at":"2015-06-15T15:36:55Z","pushed_at":"2015-11-11T14:47:28Z","git_url":"git://github.com/moneyadviceservice/mas-rad_core.git","ssh_url":"git@github.com:moneyadviceservice/mas-rad_core.git","clone_url":"https://github.com/moneyadviceservice/mas-rad_core.git","svn_url":"https://github.com/moneyadviceservice/mas-rad_core","homepage":null,"size":2047,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/pulls/129"},"html":{"href":"https://github.com/moneyadviceservice/mas-rad_core/pull/129"},"issue":{"href":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/issues/129"},"comments":{"href":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/issues/129/comments"},"review_comments":{"href":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/pulls/129/comments"},"review_comment":{"href":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/pulls/129/commits"},"statuses":{"href":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/statuses/4edb32c810603ef25bdd0fbc3824738f7e859886"}}}}