{"action":"created","comment":{"url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/pulls/comments/27312229","id":27312229,"diff_hunk":"@@ -30,6 +32,8 @@ class Service(db.Model):\n                                nullable=False)\n     data = db.Column(JSON)\n \n+    status = db.Column(db.String, index=False, unique=False, nullable=False)","path":"app/models.py","position":22,"original_position":22,"commit_id":"c6f1b053f0b0e0e09e15cf7e3b8277ea50416477","original_commit_id":"c6f1b053f0b0e0e09e15cf7e3b8277ea50416477","user":{"login":"robyoung","id":14287,"avatar_url":"https://avatars.githubusercontent.com/u/14287?v=3","gravatar_id":"","url":"https://api.github.com/users/robyoung","html_url":"https://github.com/robyoung","followers_url":"https://api.github.com/users/robyoung/followers","following_url":"https://api.github.com/users/robyoung/following{/other_user}","gists_url":"https://api.github.com/users/robyoung/gists{/gist_id}","starred_url":"https://api.github.com/users/robyoung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robyoung/subscriptions","organizations_url":"https://api.github.com/users/robyoung/orgs","repos_url":"https://api.github.com/users/robyoung/repos","events_url":"https://api.github.com/users/robyoung/events{/privacy}","received_events_url":"https://api.github.com/users/robyoung/received_events","type":"User","site_admin":false},"body":"That is a fair point. To the question of whether status should be indexed. According to some random on the internet low cardinality columns shouldn't be indexed at all.\r\nhttp://image.slidesharecdn.com/fivestepsperform2009-101006154147-phpapp01/95/5-steps-to-postgresql-performance-38-728.jpg?cb=1286398019","created_at":"2015-03-27T17:09:38Z","updated_at":"2015-03-27T17:09:38Z","html_url":"https://github.com/alphagov/digitalmarketplace-api/pull/55#discussion_r27312229","pull_request_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/pulls/55","_links":{"self":{"href":"https://api.github.com/repos/alphagov/digitalmarketplace-api/pulls/comments/27312229"},"html":{"href":"https://github.com/alphagov/digitalmarketplace-api/pull/55#discussion_r27312229"},"pull_request":{"href":"https://api.github.com/repos/alphagov/digitalmarketplace-api/pulls/55"}}},"pull_request":{"url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/pulls/55","id":32006197,"html_url":"https://github.com/alphagov/digitalmarketplace-api/pull/55","diff_url":"https://github.com/alphagov/digitalmarketplace-api/pull/55.diff","patch_url":"https://github.com/alphagov/digitalmarketplace-api/pull/55.patch","issue_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/issues/55","number":55,"state":"open","locked":false,"title":"Mi update services database for data migration","user":{"login":"minglis","id":369454,"avatar_url":"https://avatars.githubusercontent.com/u/369454?v=3","gravatar_id":"","url":"https://api.github.com/users/minglis","html_url":"https://github.com/minglis","followers_url":"https://api.github.com/users/minglis/followers","following_url":"https://api.github.com/users/minglis/following{/other_user}","gists_url":"https://api.github.com/users/minglis/gists{/gist_id}","starred_url":"https://api.github.com/users/minglis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/minglis/subscriptions","organizations_url":"https://api.github.com/users/minglis/orgs","repos_url":"https://api.github.com/users/minglis/repos","events_url":"https://api.github.com/users/minglis/events{/privacy}","received_events_url":"https://api.github.com/users/minglis/received_events","type":"User","site_admin":false},"body":"First part of delivering: https://www.pivotaltracker.com/story/show/91085102\r\n\r\nin order to add the G5 services there needed to be a couple of alterations to the services database, this pull request delivers the core updates to enable G5 and G4 to be imported. It does not however change the API interfaces to utilize these new fields other than to support their population on import.\r\n\r\n(1) New status column added.\r\n\r\nthe status column is to manage the various Boolean flags present on the G5/4 schema. These services had notions of:\r\n\r\n    - expired - relates to the overall framework - expired services are hidden from all users\r\n\r\n    - enabled - relates to admin control over visibility - disabled services hidden from suppliers and buyers but visible to admins\r\n\r\n    - status - this was a string field that allowed suppliers to publish and unpublish services - unpublished are visible to admins and suppliers but not to buyers.\r\n\r\nThese have all been rolled up into a new *status* column that has a check constraint to allow one of three values, described below,\r\n\r\n    - published: visible to buyers, suppliers and admins\r\n    - enabled: visible to  suppliers and admins \r\n    - disabled: visible only to admins\r\n\r\nthere is no logic implemented in the API to utilize these yet. This is just for information at this point. The notion of expired will be in another pull request.\r\n\r\nTo implement this there is a change in the PUT endpoint to set all services to enabled. This will need to be expanded upon when we start to use this field in anger so that we don't have unexpected side effects.\r\n\r\nThere is a migration script to set all existing services to enabled, and to then make this field not null.\r\n\r\n(2) Change type of service_id\r\nService Ids for G6 were integers, for G5 and G4 they are strings, so the DB column type has been changed to string. this impacted quite a lot of code\r\n\r\n- import script now converts ints to strings prior to PUTing the requests\r\n- endpoints that utilized the Flask path parameter type to handle validation now have to validate services_ids explicitly\r\n    \r\n    @main.route('/services/<int:service_id>', methods=['PUT'])\r\n\r\nbecomes\r\n\r\n    @main.route('/services/<string:service_id>', methods=['PUT'])\r\n\r\nso we need to do: \r\n    \r\n    if not is_valid_service_id(service_id):\r\n        abort(400, \"Invalid service id supplied\")\r\n\r\nThis impacted a lot of tests, both in terms of expectations and setups.\r\n\r\n- new validation method to do this - valid char group is\r\n   \r\n    [A-z0-9-] Alphanumeric and dashes, G5/4 is of form 5-g5-0379-325\r\n\r\n\r\n\r\n\r\n\r\n","created_at":"2015-03-26T10:49:43Z","updated_at":"2015-03-27T17:09:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d3fd52060ef19c8de607798c3da07356b98a1c5e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/pulls/55/commits","review_comments_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/pulls/55/comments","review_comment_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/pulls/comments{/number}","comments_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/issues/55/comments","statuses_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/statuses/c6f1b053f0b0e0e09e15cf7e3b8277ea50416477","head":{"label":"alphagov:mi_update_services_database_for_data_migration","ref":"mi_update_services_database_for_data_migration","sha":"c6f1b053f0b0e0e09e15cf7e3b8277ea50416477","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":26963583,"name":"digitalmarketplace-api","full_name":"alphagov/digitalmarketplace-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/digitalmarketplace-api","description":"Digital Marketplace API.","fork":false,"url":"https://api.github.com/repos/alphagov/digitalmarketplace-api","forks_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/forks","keys_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/teams","hooks_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/hooks","issue_events_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/issues/events{/number}","events_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/events","assignees_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/assignees{/user}","branches_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/branches{/branch}","tags_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/tags","blobs_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/statuses/{sha}","languages_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/languages","stargazers_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/stargazers","contributors_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/contributors","subscribers_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/subscribers","subscription_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/subscription","commits_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/contents/{+path}","compare_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/merges","archive_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/downloads","issues_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/issues{/number}","pulls_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/pulls{/number}","milestones_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/milestones{/number}","notifications_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/labels{/name}","releases_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/releases{/id}","created_at":"2014-11-21T14:41:36Z","updated_at":"2015-03-25T11:49:53Z","pushed_at":"2015-03-26T14:00:46Z","git_url":"git://github.com/alphagov/digitalmarketplace-api.git","ssh_url":"git@github.com:alphagov/digitalmarketplace-api.git","clone_url":"https://github.com/alphagov/digitalmarketplace-api.git","svn_url":"https://github.com/alphagov/digitalmarketplace-api","homepage":null,"size":1328,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":3,"forks":0,"open_issues":3,"watchers":2,"default_branch":"master"}},"base":{"label":"alphagov:master","ref":"master","sha":"eb3377493f5dcb2849498aabfa58d311d423c827","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":26963583,"name":"digitalmarketplace-api","full_name":"alphagov/digitalmarketplace-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/digitalmarketplace-api","description":"Digital Marketplace API.","fork":false,"url":"https://api.github.com/repos/alphagov/digitalmarketplace-api","forks_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/forks","keys_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/teams","hooks_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/hooks","issue_events_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/issues/events{/number}","events_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/events","assignees_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/assignees{/user}","branches_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/branches{/branch}","tags_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/tags","blobs_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/statuses/{sha}","languages_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/languages","stargazers_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/stargazers","contributors_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/contributors","subscribers_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/subscribers","subscription_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/subscription","commits_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/contents/{+path}","compare_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/merges","archive_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/downloads","issues_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/issues{/number}","pulls_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/pulls{/number}","milestones_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/milestones{/number}","notifications_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/labels{/name}","releases_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/releases{/id}","created_at":"2014-11-21T14:41:36Z","updated_at":"2015-03-25T11:49:53Z","pushed_at":"2015-03-26T14:00:46Z","git_url":"git://github.com/alphagov/digitalmarketplace-api.git","ssh_url":"git@github.com:alphagov/digitalmarketplace-api.git","clone_url":"https://github.com/alphagov/digitalmarketplace-api.git","svn_url":"https://github.com/alphagov/digitalmarketplace-api","homepage":null,"size":1328,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":3,"forks":0,"open_issues":3,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/alphagov/digitalmarketplace-api/pulls/55"},"html":{"href":"https://github.com/alphagov/digitalmarketplace-api/pull/55"},"issue":{"href":"https://api.github.com/repos/alphagov/digitalmarketplace-api/issues/55"},"comments":{"href":"https://api.github.com/repos/alphagov/digitalmarketplace-api/issues/55/comments"},"review_comments":{"href":"https://api.github.com/repos/alphagov/digitalmarketplace-api/pulls/55/comments"},"review_comment":{"href":"https://api.github.com/repos/alphagov/digitalmarketplace-api/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/alphagov/digitalmarketplace-api/pulls/55/commits"},"statuses":{"href":"https://api.github.com/repos/alphagov/digitalmarketplace-api/statuses/c6f1b053f0b0e0e09e15cf7e3b8277ea50416477"}}}}