{"action":"created","comment":{"url":"https://api.github.com/repos/alphagov/support-api/pulls/comments/32337632","id":32337632,"diff_hunk":"@@ -22,7 +22,11 @@ class AnonymousContact < ActiveRecord::Base\n   scope :only_actionable, -> { where(is_actionable: true) }\n   scope :most_recent_first, -> { order(\"created_at DESC\") }\n   scope :most_recent_last, -> { order(\"created_at ASC\") }\n-  scope :matching_path_prefix, ->(path) { where(\"anonymous_contacts.path LIKE ?\", path + \"%\") if path }\n+  scope :matching_path_prefix, ->(path) do\n+    column = SupportApi.postgresql? ? \"lower(anonymous_contacts.path)\" : \"anonymous_contacts.path\"","path":"app/models/anonymous_contact.rb","position":6,"original_position":6,"commit_id":"146752806b5d51e492d66f23a94daefa40fc804b","original_commit_id":"146752806b5d51e492d66f23a94daefa40fc804b","user":{"login":"benilovj","id":23801,"avatar_url":"https://avatars.githubusercontent.com/u/23801?v=3","gravatar_id":"","url":"https://api.github.com/users/benilovj","html_url":"https://github.com/benilovj","followers_url":"https://api.github.com/users/benilovj/followers","following_url":"https://api.github.com/users/benilovj/following{/other_user}","gists_url":"https://api.github.com/users/benilovj/gists{/gist_id}","starred_url":"https://api.github.com/users/benilovj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benilovj/subscriptions","organizations_url":"https://api.github.com/users/benilovj/orgs","repos_url":"https://api.github.com/users/benilovj/repos","events_url":"https://api.github.com/users/benilovj/events{/privacy}","received_events_url":"https://api.github.com/users/benilovj/received_events","type":"User","site_admin":false},"body":"> Shall I get rid of this then?\r\n\r\n:+1: that's the simpler solution.","created_at":"2015-06-12T17:46:46Z","updated_at":"2015-06-12T17:46:46Z","html_url":"https://github.com/alphagov/support-api/pull/63#discussion_r32337632","pull_request_url":"https://api.github.com/repos/alphagov/support-api/pulls/63","_links":{"self":{"href":"https://api.github.com/repos/alphagov/support-api/pulls/comments/32337632"},"html":{"href":"https://github.com/alphagov/support-api/pull/63#discussion_r32337632"},"pull_request":{"href":"https://api.github.com/repos/alphagov/support-api/pulls/63"}}},"pull_request":{"url":"https://api.github.com/repos/alphagov/support-api/pulls/63","id":37444029,"html_url":"https://github.com/alphagov/support-api/pull/63","diff_url":"https://github.com/alphagov/support-api/pull/63.diff","patch_url":"https://github.com/alphagov/support-api/pull/63.patch","issue_url":"https://api.github.com/repos/alphagov/support-api/issues/63","number":63,"state":"open","locked":false,"title":"Support MySQL and PostgreSQL","user":{"login":"boffbowsh","id":18276,"avatar_url":"https://avatars.githubusercontent.com/u/18276?v=3","gravatar_id":"","url":"https://api.github.com/users/boffbowsh","html_url":"https://github.com/boffbowsh","followers_url":"https://api.github.com/users/boffbowsh/followers","following_url":"https://api.github.com/users/boffbowsh/following{/other_user}","gists_url":"https://api.github.com/users/boffbowsh/gists{/gist_id}","starred_url":"https://api.github.com/users/boffbowsh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/boffbowsh/subscriptions","organizations_url":"https://api.github.com/users/boffbowsh/orgs","repos_url":"https://api.github.com/users/boffbowsh/repos","events_url":"https://api.github.com/users/boffbowsh/events{/privacy}","received_events_url":"https://api.github.com/users/boffbowsh/received_events","type":"User","site_admin":false},"body":"We need to move this app to PostgreSQL, mainly due to MySQL's query planner not being able to use multiple indexes but also in order to support future ML/sentiment analysis work, which is easier with some of the Postgres native data types.\r\n\r\nRough migration plan, please also review this:\r\n\r\n1. Deploy this. Nothing should change.\r\n2. Stop Sidekiq workers, so no new data is inserted\r\n3. Copy data, perhaps using https://github.com/maxlapshin/mysql2postgres? Fallback to exporting CSVs and importing using `COPY FROM`\r\n4. Reboot app with `SUPPORT_API_DB_TYPE=postgresql`, test.\r\n5. Restart Sidekiq workers with `SUPPORT_API_DB_TYPE=postgresql`, check new data is inserted correctly.\r\n6. Make `SUPPORT_API_DB_TYPE` changes permanent in `puppet` / `alphagov_deployment`.\r\n\r\nThe bulk of the work here is courtesy of @benilovj, I added the ability to use both DBs interchangeably, namely the backported schema dumper fix and the \"logic\" in database.yml.\r\n\r\n/cc @jennyd.","created_at":"2015-06-11T09:24:57Z","updated_at":"2015-06-12T17:46:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"65e8e69ea24ad54e741236a45831e0a9932df418","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/alphagov/support-api/pulls/63/commits","review_comments_url":"https://api.github.com/repos/alphagov/support-api/pulls/63/comments","review_comment_url":"https://api.github.com/repos/alphagov/support-api/pulls/comments{/number}","comments_url":"https://api.github.com/repos/alphagov/support-api/issues/63/comments","statuses_url":"https://api.github.com/repos/alphagov/support-api/statuses/146752806b5d51e492d66f23a94daefa40fc804b","head":{"label":"alphagov:mysql-to-postgresql","ref":"mysql-to-postgresql","sha":"146752806b5d51e492d66f23a94daefa40fc804b","user":{"login":"alphagov","id":596977,"avatar_url":"https://avatars.githubusercontent.com/u/596977?v=3","gravatar_id":"","url":"https://api.github.com/users/alphagov","html_url":"https://github.com/alphagov","followers_url":"https://api.github.com/users/alphagov/followers","following_url":"https://api.github.com/users/alphagov/following{/other_user}","gists_url":"https://api.github.com/users/alphagov/gists{/gist_id}","starred_url":"https://api.github.com/users/alphagov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphagov/subscriptions","organizations_url":"https://api.github.com/users/alphagov/orgs","repos_url":"https://api.github.com/users/alphagov/repos","events_url":"https://api.github.com/users/alphagov/events{/privacy}","received_events_url":"https://api.github.com/users/alphagov/received_events","type":"Organization","site_admin":false},"repo":{"id":20967866,"name":"support-api","full_name":"alphagov/support-api","owner":{"login":"alphagov","id":596977,"avatar_url":"https://avatars.githubusercontent.com/u/596977?v=3","gravatar_id":"","url":"https://api.github.com/users/alphagov","html_url":"https://github.com/alphagov","followers_url":"https://api.github.com/users/alphagov/followers","following_url":"https://api.github.com/users/alphagov/following{/other_user}","gists_url":"https://api.github.com/users/alphagov/gists{/gist_id}","starred_url":"https://api.github.com/users/alphagov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphagov/subscriptions","organizations_url":"https://api.github.com/users/alphagov/orgs","repos_url":"https://api.github.com/users/alphagov/repos","events_url":"https://api.github.com/users/alphagov/events{/privacy}","received_events_url":"https://api.github.com/users/alphagov/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/alphagov/support-api","description":"An API for processing GOV.UK named requests and anonymous feedback","fork":false,"url":"https://api.github.com/repos/alphagov/support-api","forks_url":"https://api.github.com/repos/alphagov/support-api/forks","keys_url":"https://api.github.com/repos/alphagov/support-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alphagov/support-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alphagov/support-api/teams","hooks_url":"https://api.github.com/repos/alphagov/support-api/hooks","issue_events_url":"https://api.github.com/repos/alphagov/support-api/issues/events{/number}","events_url":"https://api.github.com/repos/alphagov/support-api/events","assignees_url":"https://api.github.com/repos/alphagov/support-api/assignees{/user}","branches_url":"https://api.github.com/repos/alphagov/support-api/branches{/branch}","tags_url":"https://api.github.com/repos/alphagov/support-api/tags","blobs_url":"https://api.github.com/repos/alphagov/support-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alphagov/support-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alphagov/support-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/alphagov/support-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alphagov/support-api/statuses/{sha}","languages_url":"https://api.github.com/repos/alphagov/support-api/languages","stargazers_url":"https://api.github.com/repos/alphagov/support-api/stargazers","contributors_url":"https://api.github.com/repos/alphagov/support-api/contributors","subscribers_url":"https://api.github.com/repos/alphagov/support-api/subscribers","subscription_url":"https://api.github.com/repos/alphagov/support-api/subscription","commits_url":"https://api.github.com/repos/alphagov/support-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/alphagov/support-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/alphagov/support-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/alphagov/support-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/alphagov/support-api/contents/{+path}","compare_url":"https://api.github.com/repos/alphagov/support-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alphagov/support-api/merges","archive_url":"https://api.github.com/repos/alphagov/support-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alphagov/support-api/downloads","issues_url":"https://api.github.com/repos/alphagov/support-api/issues{/number}","pulls_url":"https://api.github.com/repos/alphagov/support-api/pulls{/number}","milestones_url":"https://api.github.com/repos/alphagov/support-api/milestones{/number}","notifications_url":"https://api.github.com/repos/alphagov/support-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alphagov/support-api/labels{/name}","releases_url":"https://api.github.com/repos/alphagov/support-api/releases{/id}","created_at":"2014-06-18T15:43:38Z","updated_at":"2015-05-06T12:48:58Z","pushed_at":"2015-06-12T16:26:11Z","git_url":"git://github.com/alphagov/support-api.git","ssh_url":"git@github.com:alphagov/support-api.git","clone_url":"https://github.com/alphagov/support-api.git","svn_url":"https://github.com/alphagov/support-api","homepage":"","size":1691,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":1,"default_branch":"master"}},"base":{"label":"alphagov:master","ref":"master","sha":"bf639646c3fdb7195b8f7d0e3559bd10eff8f9da","user":{"login":"alphagov","id":596977,"avatar_url":"https://avatars.githubusercontent.com/u/596977?v=3","gravatar_id":"","url":"https://api.github.com/users/alphagov","html_url":"https://github.com/alphagov","followers_url":"https://api.github.com/users/alphagov/followers","following_url":"https://api.github.com/users/alphagov/following{/other_user}","gists_url":"https://api.github.com/users/alphagov/gists{/gist_id}","starred_url":"https://api.github.com/users/alphagov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphagov/subscriptions","organizations_url":"https://api.github.com/users/alphagov/orgs","repos_url":"https://api.github.com/users/alphagov/repos","events_url":"https://api.github.com/users/alphagov/events{/privacy}","received_events_url":"https://api.github.com/users/alphagov/received_events","type":"Organization","site_admin":false},"repo":{"id":20967866,"name":"support-api","full_name":"alphagov/support-api","owner":{"login":"alphagov","id":596977,"avatar_url":"https://avatars.githubusercontent.com/u/596977?v=3","gravatar_id":"","url":"https://api.github.com/users/alphagov","html_url":"https://github.com/alphagov","followers_url":"https://api.github.com/users/alphagov/followers","following_url":"https://api.github.com/users/alphagov/following{/other_user}","gists_url":"https://api.github.com/users/alphagov/gists{/gist_id}","starred_url":"https://api.github.com/users/alphagov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphagov/subscriptions","organizations_url":"https://api.github.com/users/alphagov/orgs","repos_url":"https://api.github.com/users/alphagov/repos","events_url":"https://api.github.com/users/alphagov/events{/privacy}","received_events_url":"https://api.github.com/users/alphagov/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/alphagov/support-api","description":"An API for processing GOV.UK named requests and anonymous feedback","fork":false,"url":"https://api.github.com/repos/alphagov/support-api","forks_url":"https://api.github.com/repos/alphagov/support-api/forks","keys_url":"https://api.github.com/repos/alphagov/support-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alphagov/support-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alphagov/support-api/teams","hooks_url":"https://api.github.com/repos/alphagov/support-api/hooks","issue_events_url":"https://api.github.com/repos/alphagov/support-api/issues/events{/number}","events_url":"https://api.github.com/repos/alphagov/support-api/events","assignees_url":"https://api.github.com/repos/alphagov/support-api/assignees{/user}","branches_url":"https://api.github.com/repos/alphagov/support-api/branches{/branch}","tags_url":"https://api.github.com/repos/alphagov/support-api/tags","blobs_url":"https://api.github.com/repos/alphagov/support-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alphagov/support-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alphagov/support-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/alphagov/support-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alphagov/support-api/statuses/{sha}","languages_url":"https://api.github.com/repos/alphagov/support-api/languages","stargazers_url":"https://api.github.com/repos/alphagov/support-api/stargazers","contributors_url":"https://api.github.com/repos/alphagov/support-api/contributors","subscribers_url":"https://api.github.com/repos/alphagov/support-api/subscribers","subscription_url":"https://api.github.com/repos/alphagov/support-api/subscription","commits_url":"https://api.github.com/repos/alphagov/support-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/alphagov/support-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/alphagov/support-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/alphagov/support-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/alphagov/support-api/contents/{+path}","compare_url":"https://api.github.com/repos/alphagov/support-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alphagov/support-api/merges","archive_url":"https://api.github.com/repos/alphagov/support-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alphagov/support-api/downloads","issues_url":"https://api.github.com/repos/alphagov/support-api/issues{/number}","pulls_url":"https://api.github.com/repos/alphagov/support-api/pulls{/number}","milestones_url":"https://api.github.com/repos/alphagov/support-api/milestones{/number}","notifications_url":"https://api.github.com/repos/alphagov/support-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alphagov/support-api/labels{/name}","releases_url":"https://api.github.com/repos/alphagov/support-api/releases{/id}","created_at":"2014-06-18T15:43:38Z","updated_at":"2015-05-06T12:48:58Z","pushed_at":"2015-06-12T16:26:11Z","git_url":"git://github.com/alphagov/support-api.git","ssh_url":"git@github.com:alphagov/support-api.git","clone_url":"https://github.com/alphagov/support-api.git","svn_url":"https://github.com/alphagov/support-api","homepage":"","size":1691,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/alphagov/support-api/pulls/63"},"html":{"href":"https://github.com/alphagov/support-api/pull/63"},"issue":{"href":"https://api.github.com/repos/alphagov/support-api/issues/63"},"comments":{"href":"https://api.github.com/repos/alphagov/support-api/issues/63/comments"},"review_comments":{"href":"https://api.github.com/repos/alphagov/support-api/pulls/63/comments"},"review_comment":{"href":"https://api.github.com/repos/alphagov/support-api/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/alphagov/support-api/pulls/63/commits"},"statuses":{"href":"https://api.github.com/repos/alphagov/support-api/statuses/146752806b5d51e492d66f23a94daefa40fc804b"}}}}