{"action":"created","comment":{"url":"https://api.github.com/repos/Clever/flag-bearer/pulls/comments/53511841","id":53511841,"diff_hunk":"@@ -0,0 +1,238 @@\n+package db\n+\n+import (\n+\t\"database/sql\"\n+\t\"strings\"\n+\t\"time\"\n+\n+\t\"github.com/Clever/flag-bearer/models\"\n+\t\"github.com/go-sql-driver/mysql\"\n+\t\"github.com/mattn/go-sqlite3\"\n+)\n+\n+func timeToStringPtr(timestamp time.Time) *string {\n+\tstr := timestamp.Format(time.RFC3339)\n+\treturn &str\n+}\n+\n+// MySQLDb represents a MySQL-backed feature flag database.\n+type MySQLDb struct {\n+\tdb *sql.DB\n+}\n+\n+// CreateTablesMySQL creates all of the tables required for this backend. If the tables already exists,\n+// it does nothing.\n+func (m *MySQLDb) CreateTablesMySQL() error {\n+\tfeaturesSchema := `\n+CREATE TABLE IF NOT EXISTS features (\n+  name varchar(255) NOT NULL,\n+  description varchar(10240) NOT NULL,\n+  created_on TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n+  PRIMARY KEY (name)\n+)\n+`\n+\tfeaturesUsersSchema := `\n+CREATE TABLE IF NOT EXISTS features_users (\n+  user varchar(255) NOT NULL,\n+  feature varchar(255) NOT NULL,\n+  UNIQUE KEY (user, feature),\n+  INDEX (user),","path":"db/mysql.go","position":39,"original_position":39,"commit_id":"f6a2a1f2239a65bd5b4664f584c3d2a78f6f2d1e","original_commit_id":"f6a2a1f2239a65bd5b4664f584c3d2a78f6f2d1e","user":{"login":"azylman","id":790102,"avatar_url":"https://avatars.githubusercontent.com/u/790102?v=3","gravatar_id":"","url":"https://api.github.com/users/azylman","html_url":"https://github.com/azylman","followers_url":"https://api.github.com/users/azylman/followers","following_url":"https://api.github.com/users/azylman/following{/other_user}","gists_url":"https://api.github.com/users/azylman/gists{/gist_id}","starred_url":"https://api.github.com/users/azylman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/azylman/subscriptions","organizations_url":"https://api.github.com/users/azylman/orgs","repos_url":"https://api.github.com/users/azylman/repos","events_url":"https://api.github.com/users/azylman/events{/privacy}","received_events_url":"https://api.github.com/users/azylman/received_events","type":"User","site_admin":false},"body":"to make sure I understand it properly: `(user, feature)` can be used for queries that just have the user, but not ones that just have the feature, right?","created_at":"2016-02-19T20:09:22Z","updated_at":"2016-02-19T20:09:22Z","html_url":"https://github.com/Clever/flag-bearer/pull/27#discussion_r53511841","pull_request_url":"https://api.github.com/repos/Clever/flag-bearer/pulls/27","_links":{"self":{"href":"https://api.github.com/repos/Clever/flag-bearer/pulls/comments/53511841"},"html":{"href":"https://github.com/Clever/flag-bearer/pull/27#discussion_r53511841"},"pull_request":{"href":"https://api.github.com/repos/Clever/flag-bearer/pulls/27"}}},"pull_request":{"url":"https://api.github.com/repos/Clever/flag-bearer/pulls/27","id":59728150,"html_url":"https://github.com/Clever/flag-bearer/pull/27","diff_url":"https://github.com/Clever/flag-bearer/pull/27.diff","patch_url":"https://github.com/Clever/flag-bearer/pull/27.patch","issue_url":"https://api.github.com/repos/Clever/flag-bearer/issues/27","number":27,"state":"open","locked":false,"title":"add mysql backend","user":{"login":"azylman","id":790102,"avatar_url":"https://avatars.githubusercontent.com/u/790102?v=3","gravatar_id":"","url":"https://api.github.com/users/azylman","html_url":"https://github.com/azylman","followers_url":"https://api.github.com/users/azylman/followers","following_url":"https://api.github.com/users/azylman/following{/other_user}","gists_url":"https://api.github.com/users/azylman/gists{/gist_id}","starred_url":"https://api.github.com/users/azylman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/azylman/subscriptions","organizations_url":"https://api.github.com/users/azylman/orgs","repos_url":"https://api.github.com/users/azylman/repos","events_url":"https://api.github.com/users/azylman/events{/privacy}","received_events_url":"https://api.github.com/users/azylman/received_events","type":"User","site_admin":false},"body":"It also supports sqlite, just to make local development easier. The only differences is how constraint violations (unique keys or foreign keys) are handled and how tables are created, all of the other logic is the same.\r\n\r\nIt'll run against both sqlite and mysql in drone, but only sqlite if you run `make test`","created_at":"2016-02-17T23:40:04Z","updated_at":"2016-02-19T20:09:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"343ee3cf2150ba4c0600d14ce7c03a81b41e12a3","assignee":{"login":"kvigen","id":5514539,"avatar_url":"https://avatars.githubusercontent.com/u/5514539?v=3","gravatar_id":"","url":"https://api.github.com/users/kvigen","html_url":"https://github.com/kvigen","followers_url":"https://api.github.com/users/kvigen/followers","following_url":"https://api.github.com/users/kvigen/following{/other_user}","gists_url":"https://api.github.com/users/kvigen/gists{/gist_id}","starred_url":"https://api.github.com/users/kvigen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kvigen/subscriptions","organizations_url":"https://api.github.com/users/kvigen/orgs","repos_url":"https://api.github.com/users/kvigen/repos","events_url":"https://api.github.com/users/kvigen/events{/privacy}","received_events_url":"https://api.github.com/users/kvigen/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/Clever/flag-bearer/pulls/27/commits","review_comments_url":"https://api.github.com/repos/Clever/flag-bearer/pulls/27/comments","review_comment_url":"https://api.github.com/repos/Clever/flag-bearer/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Clever/flag-bearer/issues/27/comments","statuses_url":"https://api.github.com/repos/Clever/flag-bearer/statuses/f6a2a1f2239a65bd5b4664f584c3d2a78f6f2d1e","head":{"label":"Clever:sql","ref":"sql","sha":"f6a2a1f2239a65bd5b4664f584c3d2a78f6f2d1e","user":{"login":"Clever","id":1885509,"avatar_url":"https://avatars.githubusercontent.com/u/1885509?v=3","gravatar_id":"","url":"https://api.github.com/users/Clever","html_url":"https://github.com/Clever","followers_url":"https://api.github.com/users/Clever/followers","following_url":"https://api.github.com/users/Clever/following{/other_user}","gists_url":"https://api.github.com/users/Clever/gists{/gist_id}","starred_url":"https://api.github.com/users/Clever/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Clever/subscriptions","organizations_url":"https://api.github.com/users/Clever/orgs","repos_url":"https://api.github.com/users/Clever/repos","events_url":"https://api.github.com/users/Clever/events{/privacy}","received_events_url":"https://api.github.com/users/Clever/received_events","type":"Organization","site_admin":false},"repo":{"id":37881095,"name":"flag-bearer","full_name":"Clever/flag-bearer","owner":{"login":"Clever","id":1885509,"avatar_url":"https://avatars.githubusercontent.com/u/1885509?v=3","gravatar_id":"","url":"https://api.github.com/users/Clever","html_url":"https://github.com/Clever","followers_url":"https://api.github.com/users/Clever/followers","following_url":"https://api.github.com/users/Clever/following{/other_user}","gists_url":"https://api.github.com/users/Clever/gists{/gist_id}","starred_url":"https://api.github.com/users/Clever/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Clever/subscriptions","organizations_url":"https://api.github.com/users/Clever/orgs","repos_url":"https://api.github.com/users/Clever/repos","events_url":"https://api.github.com/users/Clever/events{/privacy}","received_events_url":"https://api.github.com/users/Clever/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Clever/flag-bearer","description":"A service to manage feature flags.","fork":false,"url":"https://api.github.com/repos/Clever/flag-bearer","forks_url":"https://api.github.com/repos/Clever/flag-bearer/forks","keys_url":"https://api.github.com/repos/Clever/flag-bearer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Clever/flag-bearer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Clever/flag-bearer/teams","hooks_url":"https://api.github.com/repos/Clever/flag-bearer/hooks","issue_events_url":"https://api.github.com/repos/Clever/flag-bearer/issues/events{/number}","events_url":"https://api.github.com/repos/Clever/flag-bearer/events","assignees_url":"https://api.github.com/repos/Clever/flag-bearer/assignees{/user}","branches_url":"https://api.github.com/repos/Clever/flag-bearer/branches{/branch}","tags_url":"https://api.github.com/repos/Clever/flag-bearer/tags","blobs_url":"https://api.github.com/repos/Clever/flag-bearer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Clever/flag-bearer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Clever/flag-bearer/git/refs{/sha}","trees_url":"https://api.github.com/repos/Clever/flag-bearer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Clever/flag-bearer/statuses/{sha}","languages_url":"https://api.github.com/repos/Clever/flag-bearer/languages","stargazers_url":"https://api.github.com/repos/Clever/flag-bearer/stargazers","contributors_url":"https://api.github.com/repos/Clever/flag-bearer/contributors","subscribers_url":"https://api.github.com/repos/Clever/flag-bearer/subscribers","subscription_url":"https://api.github.com/repos/Clever/flag-bearer/subscription","commits_url":"https://api.github.com/repos/Clever/flag-bearer/commits{/sha}","git_commits_url":"https://api.github.com/repos/Clever/flag-bearer/git/commits{/sha}","comments_url":"https://api.github.com/repos/Clever/flag-bearer/comments{/number}","issue_comment_url":"https://api.github.com/repos/Clever/flag-bearer/issues/comments{/number}","contents_url":"https://api.github.com/repos/Clever/flag-bearer/contents/{+path}","compare_url":"https://api.github.com/repos/Clever/flag-bearer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Clever/flag-bearer/merges","archive_url":"https://api.github.com/repos/Clever/flag-bearer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Clever/flag-bearer/downloads","issues_url":"https://api.github.com/repos/Clever/flag-bearer/issues{/number}","pulls_url":"https://api.github.com/repos/Clever/flag-bearer/pulls{/number}","milestones_url":"https://api.github.com/repos/Clever/flag-bearer/milestones{/number}","notifications_url":"https://api.github.com/repos/Clever/flag-bearer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Clever/flag-bearer/labels{/name}","releases_url":"https://api.github.com/repos/Clever/flag-bearer/releases{/id}","deployments_url":"https://api.github.com/repos/Clever/flag-bearer/deployments","created_at":"2015-06-22T21:17:26Z","updated_at":"2016-01-25T23:31:06Z","pushed_at":"2016-02-18T01:32:55Z","git_url":"git://github.com/Clever/flag-bearer.git","ssh_url":"git@github.com:Clever/flag-bearer.git","clone_url":"https://github.com/Clever/flag-bearer.git","svn_url":"https://github.com/Clever/flag-bearer","homepage":null,"size":3436,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"Clever:master","ref":"master","sha":"088d0a8919ccf65bc0c5747d7ad68189c26f4e60","user":{"login":"Clever","id":1885509,"avatar_url":"https://avatars.githubusercontent.com/u/1885509?v=3","gravatar_id":"","url":"https://api.github.com/users/Clever","html_url":"https://github.com/Clever","followers_url":"https://api.github.com/users/Clever/followers","following_url":"https://api.github.com/users/Clever/following{/other_user}","gists_url":"https://api.github.com/users/Clever/gists{/gist_id}","starred_url":"https://api.github.com/users/Clever/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Clever/subscriptions","organizations_url":"https://api.github.com/users/Clever/orgs","repos_url":"https://api.github.com/users/Clever/repos","events_url":"https://api.github.com/users/Clever/events{/privacy}","received_events_url":"https://api.github.com/users/Clever/received_events","type":"Organization","site_admin":false},"repo":{"id":37881095,"name":"flag-bearer","full_name":"Clever/flag-bearer","owner":{"login":"Clever","id":1885509,"avatar_url":"https://avatars.githubusercontent.com/u/1885509?v=3","gravatar_id":"","url":"https://api.github.com/users/Clever","html_url":"https://github.com/Clever","followers_url":"https://api.github.com/users/Clever/followers","following_url":"https://api.github.com/users/Clever/following{/other_user}","gists_url":"https://api.github.com/users/Clever/gists{/gist_id}","starred_url":"https://api.github.com/users/Clever/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Clever/subscriptions","organizations_url":"https://api.github.com/users/Clever/orgs","repos_url":"https://api.github.com/users/Clever/repos","events_url":"https://api.github.com/users/Clever/events{/privacy}","received_events_url":"https://api.github.com/users/Clever/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Clever/flag-bearer","description":"A service to manage feature flags.","fork":false,"url":"https://api.github.com/repos/Clever/flag-bearer","forks_url":"https://api.github.com/repos/Clever/flag-bearer/forks","keys_url":"https://api.github.com/repos/Clever/flag-bearer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Clever/flag-bearer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Clever/flag-bearer/teams","hooks_url":"https://api.github.com/repos/Clever/flag-bearer/hooks","issue_events_url":"https://api.github.com/repos/Clever/flag-bearer/issues/events{/number}","events_url":"https://api.github.com/repos/Clever/flag-bearer/events","assignees_url":"https://api.github.com/repos/Clever/flag-bearer/assignees{/user}","branches_url":"https://api.github.com/repos/Clever/flag-bearer/branches{/branch}","tags_url":"https://api.github.com/repos/Clever/flag-bearer/tags","blobs_url":"https://api.github.com/repos/Clever/flag-bearer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Clever/flag-bearer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Clever/flag-bearer/git/refs{/sha}","trees_url":"https://api.github.com/repos/Clever/flag-bearer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Clever/flag-bearer/statuses/{sha}","languages_url":"https://api.github.com/repos/Clever/flag-bearer/languages","stargazers_url":"https://api.github.com/repos/Clever/flag-bearer/stargazers","contributors_url":"https://api.github.com/repos/Clever/flag-bearer/contributors","subscribers_url":"https://api.github.com/repos/Clever/flag-bearer/subscribers","subscription_url":"https://api.github.com/repos/Clever/flag-bearer/subscription","commits_url":"https://api.github.com/repos/Clever/flag-bearer/commits{/sha}","git_commits_url":"https://api.github.com/repos/Clever/flag-bearer/git/commits{/sha}","comments_url":"https://api.github.com/repos/Clever/flag-bearer/comments{/number}","issue_comment_url":"https://api.github.com/repos/Clever/flag-bearer/issues/comments{/number}","contents_url":"https://api.github.com/repos/Clever/flag-bearer/contents/{+path}","compare_url":"https://api.github.com/repos/Clever/flag-bearer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Clever/flag-bearer/merges","archive_url":"https://api.github.com/repos/Clever/flag-bearer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Clever/flag-bearer/downloads","issues_url":"https://api.github.com/repos/Clever/flag-bearer/issues{/number}","pulls_url":"https://api.github.com/repos/Clever/flag-bearer/pulls{/number}","milestones_url":"https://api.github.com/repos/Clever/flag-bearer/milestones{/number}","notifications_url":"https://api.github.com/repos/Clever/flag-bearer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Clever/flag-bearer/labels{/name}","releases_url":"https://api.github.com/repos/Clever/flag-bearer/releases{/id}","deployments_url":"https://api.github.com/repos/Clever/flag-bearer/deployments","created_at":"2015-06-22T21:17:26Z","updated_at":"2016-01-25T23:31:06Z","pushed_at":"2016-02-18T01:32:55Z","git_url":"git://github.com/Clever/flag-bearer.git","ssh_url":"git@github.com:Clever/flag-bearer.git","clone_url":"https://github.com/Clever/flag-bearer.git","svn_url":"https://github.com/Clever/flag-bearer","homepage":null,"size":3436,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Clever/flag-bearer/pulls/27"},"html":{"href":"https://github.com/Clever/flag-bearer/pull/27"},"issue":{"href":"https://api.github.com/repos/Clever/flag-bearer/issues/27"},"comments":{"href":"https://api.github.com/repos/Clever/flag-bearer/issues/27/comments"},"review_comments":{"href":"https://api.github.com/repos/Clever/flag-bearer/pulls/27/comments"},"review_comment":{"href":"https://api.github.com/repos/Clever/flag-bearer/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Clever/flag-bearer/pulls/27/commits"},"statuses":{"href":"https://api.github.com/repos/Clever/flag-bearer/statuses/f6a2a1f2239a65bd5b4664f584c3d2a78f6f2d1e"}}}}