{"action":"reopened","number":278,"pull_request":{"url":"https://api.github.com/repos/almighty/almighty-core/pulls/278","id":86901454,"html_url":"https://github.com/almighty/almighty-core/pull/278","diff_url":"https://github.com/almighty/almighty-core/pull/278.diff","patch_url":"https://github.com/almighty/almighty-core/pull/278.patch","issue_url":"https://api.github.com/repos/almighty/almighty-core/issues/278","number":278,"state":"open","locked":false,"title":"Support migration of the database schema and data","user":{"login":"kwk","id":193408,"avatar_url":"https://avatars.githubusercontent.com/u/193408?v=3","gravatar_id":"","url":"https://api.github.com/users/kwk","html_url":"https://github.com/kwk","followers_url":"https://api.github.com/users/kwk/followers","following_url":"https://api.github.com/users/kwk/following{/other_user}","gists_url":"https://api.github.com/users/kwk/gists{/gist_id}","starred_url":"https://api.github.com/users/kwk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kwk/subscriptions","organizations_url":"https://api.github.com/users/kwk/orgs","repos_url":"https://api.github.com/users/kwk/repos","events_url":"https://api.github.com/users/kwk/events{/privacy}","received_events_url":"https://api.github.com/users/kwk/received_events","type":"User","site_admin":false},"body":"Fixes #184 \r\n\r\nTo be able to have all `migration/sql-files/*.sql` files bundled in the alm core binary, I've used go-bindata to pack them intothe `migration/sqlbindata.go` file. The prefix `migration/sql-files` is removed from the filepaths inside of `migration/sqlbinata.go`.\r\n\r\nThe purpose of the `migration/sql-files` is to store all files that are relevant for updating the database over time.\r\n\r\nThe SQL files themselves are packaged into the alm core binary with [go-bindata](https://github.com/jteeuwen/go-bindata).\r\n\r\nThe filenames of the SQL files have no meaning but we prefix them with the version they stand for so it is easier to find out what's happening. The `migration.go` file has the control over the updates and the SQL files are *not* blindly executed just because they exist. Instead we allow the developers to run Go code as well.\r\n\r\n## Version 0\r\n\r\nThe first sql file (`./migration/sql-files/000-bootstrap.sql`) creates the basic layout of the versioning table.\r\n\r\n### Database table layout\r\n\r\nThis is how the `version` table looks like in Postgres:\r\n\r\n```\r\npostgres=# select * from version;\r\n id |          updated_at           | version \r\n----+-------------------------------+---------\r\n  1 | 2016-09-27 10:13:30.423206+00 |       0\r\n(1 row)\r\n```\r\n\r\nThe auto migration portion in migration/migration.go has been removed.\r\n\r\nLogic to get the current version and to execute all remaining version is implemented.\r\n\r\n## Migrate at startup of core\r\n\r\nThis is how the migration looks like when the core starts up\r\n```\r\n$./bin/alm\r\n2016/09/27 12:13:30 Running as user name \"kkleine\" with UID 1000.\r\n2016/09/27 12:13:30 Opening DB connection attempt 1 of 50\r\n2016/09/27 12:13:30 Attempt to update DB to version 0\r\n\r\n(/home/kkleine/go/src/github.com/almighty/almighty-core/migration/migration.go:44) \r\n[2016-09-27 12:13:30]  [13.01ms]  -- This table sets the foundation for all future database migrations.\r\ncreate table \"version\" (\r\n  \"id\" serial primary key,\r\n  \"updated_at\" timestamp with time zone not null default current_timestamp,\r\n  \"version\" int unique not null\r\n);\r\n\r\n(/home/kkleine/go/src/github.com/almighty/almighty-core/migration/migration.go:114) \r\n[2016-09-27 12:13:30]  [1.54ms]  insert into version (version) values('0')\r\n2016/09/27 12:13:30 Successfully updated DB to version 0\r\n```","created_at":"2016-09-27T10:22:48Z","updated_at":"2016-09-27T16:34:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"324cde5d1a32eb41a0e651b690481784ae912785","assignee":{"login":"kwk","id":193408,"avatar_url":"https://avatars.githubusercontent.com/u/193408?v=3","gravatar_id":"","url":"https://api.github.com/users/kwk","html_url":"https://github.com/kwk","followers_url":"https://api.github.com/users/kwk/followers","following_url":"https://api.github.com/users/kwk/following{/other_user}","gists_url":"https://api.github.com/users/kwk/gists{/gist_id}","starred_url":"https://api.github.com/users/kwk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kwk/subscriptions","organizations_url":"https://api.github.com/users/kwk/orgs","repos_url":"https://api.github.com/users/kwk/repos","events_url":"https://api.github.com/users/kwk/events{/privacy}","received_events_url":"https://api.github.com/users/kwk/received_events","type":"User","site_admin":false},"assignees":[{"login":"kwk","id":193408,"avatar_url":"https://avatars.githubusercontent.com/u/193408?v=3","gravatar_id":"","url":"https://api.github.com/users/kwk","html_url":"https://github.com/kwk","followers_url":"https://api.github.com/users/kwk/followers","following_url":"https://api.github.com/users/kwk/following{/other_user}","gists_url":"https://api.github.com/users/kwk/gists{/gist_id}","starred_url":"https://api.github.com/users/kwk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kwk/subscriptions","organizations_url":"https://api.github.com/users/kwk/orgs","repos_url":"https://api.github.com/users/kwk/repos","events_url":"https://api.github.com/users/kwk/events{/privacy}","received_events_url":"https://api.github.com/users/kwk/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/almighty/almighty-core/milestones/5","html_url":"https://github.com/almighty/almighty-core/milestones/Sprint%20%23121","labels_url":"https://api.github.com/repos/almighty/almighty-core/milestones/5/labels","id":2028780,"number":5,"title":"Sprint #121","description":"Goals: https://github.com/almighty/almighty-core/issues/284\r\n","creator":{"login":"maxandersen","id":54129,"avatar_url":"https://avatars.githubusercontent.com/u/54129?v=3","gravatar_id":"","url":"https://api.github.com/users/maxandersen","html_url":"https://github.com/maxandersen","followers_url":"https://api.github.com/users/maxandersen/followers","following_url":"https://api.github.com/users/maxandersen/following{/other_user}","gists_url":"https://api.github.com/users/maxandersen/gists{/gist_id}","starred_url":"https://api.github.com/users/maxandersen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maxandersen/subscriptions","organizations_url":"https://api.github.com/users/maxandersen/orgs","repos_url":"https://api.github.com/users/maxandersen/repos","events_url":"https://api.github.com/users/maxandersen/events{/privacy}","received_events_url":"https://api.github.com/users/maxandersen/received_events","type":"User","site_admin":false},"open_issues":4,"closed_issues":0,"state":"open","created_at":"2016-09-26T13:04:27Z","updated_at":"2016-09-27T16:34:28Z","due_on":"2016-10-18T00:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/almighty/almighty-core/pulls/278/commits","review_comments_url":"https://api.github.com/repos/almighty/almighty-core/pulls/278/comments","review_comment_url":"https://api.github.com/repos/almighty/almighty-core/pulls/comments{/number}","comments_url":"https://api.github.com/repos/almighty/almighty-core/issues/278/comments","statuses_url":"https://api.github.com/repos/almighty/almighty-core/statuses/e43b2a0c2e2adee271452c8e68b3039011b4a30a","head":{"label":"kwk:fix-184","ref":"fix-184","sha":"e43b2a0c2e2adee271452c8e68b3039011b4a30a","user":{"login":"kwk","id":193408,"avatar_url":"https://avatars.githubusercontent.com/u/193408?v=3","gravatar_id":"","url":"https://api.github.com/users/kwk","html_url":"https://github.com/kwk","followers_url":"https://api.github.com/users/kwk/followers","following_url":"https://api.github.com/users/kwk/following{/other_user}","gists_url":"https://api.github.com/users/kwk/gists{/gist_id}","starred_url":"https://api.github.com/users/kwk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kwk/subscriptions","organizations_url":"https://api.github.com/users/kwk/orgs","repos_url":"https://api.github.com/users/kwk/repos","events_url":"https://api.github.com/users/kwk/events{/privacy}","received_events_url":"https://api.github.com/users/kwk/received_events","type":"User","site_admin":false},"repo":{"id":61216531,"name":"almighty-core","full_name":"kwk/almighty-core","owner":{"login":"kwk","id":193408,"avatar_url":"https://avatars.githubusercontent.com/u/193408?v=3","gravatar_id":"","url":"https://api.github.com/users/kwk","html_url":"https://github.com/kwk","followers_url":"https://api.github.com/users/kwk/followers","following_url":"https://api.github.com/users/kwk/following{/other_user}","gists_url":"https://api.github.com/users/kwk/gists{/gist_id}","starred_url":"https://api.github.com/users/kwk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kwk/subscriptions","organizations_url":"https://api.github.com/users/kwk/orgs","repos_url":"https://api.github.com/users/kwk/repos","events_url":"https://api.github.com/users/kwk/events{/privacy}","received_events_url":"https://api.github.com/users/kwk/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kwk/almighty-core","description":"","fork":true,"url":"https://api.github.com/repos/kwk/almighty-core","forks_url":"https://api.github.com/repos/kwk/almighty-core/forks","keys_url":"https://api.github.com/repos/kwk/almighty-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kwk/almighty-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kwk/almighty-core/teams","hooks_url":"https://api.github.com/repos/kwk/almighty-core/hooks","issue_events_url":"https://api.github.com/repos/kwk/almighty-core/issues/events{/number}","events_url":"https://api.github.com/repos/kwk/almighty-core/events","assignees_url":"https://api.github.com/repos/kwk/almighty-core/assignees{/user}","branches_url":"https://api.github.com/repos/kwk/almighty-core/branches{/branch}","tags_url":"https://api.github.com/repos/kwk/almighty-core/tags","blobs_url":"https://api.github.com/repos/kwk/almighty-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kwk/almighty-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kwk/almighty-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/kwk/almighty-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kwk/almighty-core/statuses/{sha}","languages_url":"https://api.github.com/repos/kwk/almighty-core/languages","stargazers_url":"https://api.github.com/repos/kwk/almighty-core/stargazers","contributors_url":"https://api.github.com/repos/kwk/almighty-core/contributors","subscribers_url":"https://api.github.com/repos/kwk/almighty-core/subscribers","subscription_url":"https://api.github.com/repos/kwk/almighty-core/subscription","commits_url":"https://api.github.com/repos/kwk/almighty-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/kwk/almighty-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/kwk/almighty-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/kwk/almighty-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/kwk/almighty-core/contents/{+path}","compare_url":"https://api.github.com/repos/kwk/almighty-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kwk/almighty-core/merges","archive_url":"https://api.github.com/repos/kwk/almighty-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kwk/almighty-core/downloads","issues_url":"https://api.github.com/repos/kwk/almighty-core/issues{/number}","pulls_url":"https://api.github.com/repos/kwk/almighty-core/pulls{/number}","milestones_url":"https://api.github.com/repos/kwk/almighty-core/milestones{/number}","notifications_url":"https://api.github.com/repos/kwk/almighty-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kwk/almighty-core/labels{/name}","releases_url":"https://api.github.com/repos/kwk/almighty-core/releases{/id}","deployments_url":"https://api.github.com/repos/kwk/almighty-core/deployments","created_at":"2016-06-15T14:55:29Z","updated_at":"2016-06-15T14:55:30Z","pushed_at":"2016-09-27T13:41:37Z","git_url":"git://github.com/kwk/almighty-core.git","ssh_url":"git@github.com:kwk/almighty-core.git","clone_url":"https://github.com/kwk/almighty-core.git","svn_url":"https://github.com/kwk/almighty-core","homepage":null,"size":409,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"almighty:master","ref":"master","sha":"f3a5914b51e967204c63d5803e5e0b2f96496b95","user":{"login":"almighty","id":17783151,"avatar_url":"https://avatars.githubusercontent.com/u/17783151?v=3","gravatar_id":"","url":"https://api.github.com/users/almighty","html_url":"https://github.com/almighty","followers_url":"https://api.github.com/users/almighty/followers","following_url":"https://api.github.com/users/almighty/following{/other_user}","gists_url":"https://api.github.com/users/almighty/gists{/gist_id}","starred_url":"https://api.github.com/users/almighty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/almighty/subscriptions","organizations_url":"https://api.github.com/users/almighty/orgs","repos_url":"https://api.github.com/users/almighty/repos","events_url":"https://api.github.com/users/almighty/events{/privacy}","received_events_url":"https://api.github.com/users/almighty/received_events","type":"Organization","site_admin":false},"repo":{"id":54260706,"name":"almighty-core","full_name":"almighty/almighty-core","owner":{"login":"almighty","id":17783151,"avatar_url":"https://avatars.githubusercontent.com/u/17783151?v=3","gravatar_id":"","url":"https://api.github.com/users/almighty","html_url":"https://github.com/almighty","followers_url":"https://api.github.com/users/almighty/followers","following_url":"https://api.github.com/users/almighty/following{/other_user}","gists_url":"https://api.github.com/users/almighty/gists{/gist_id}","starred_url":"https://api.github.com/users/almighty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/almighty/subscriptions","organizations_url":"https://api.github.com/users/almighty/orgs","repos_url":"https://api.github.com/users/almighty/repos","events_url":"https://api.github.com/users/almighty/events{/privacy}","received_events_url":"https://api.github.com/users/almighty/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/almighty/almighty-core","description":"","fork":false,"url":"https://api.github.com/repos/almighty/almighty-core","forks_url":"https://api.github.com/repos/almighty/almighty-core/forks","keys_url":"https://api.github.com/repos/almighty/almighty-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/almighty/almighty-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/almighty/almighty-core/teams","hooks_url":"https://api.github.com/repos/almighty/almighty-core/hooks","issue_events_url":"https://api.github.com/repos/almighty/almighty-core/issues/events{/number}","events_url":"https://api.github.com/repos/almighty/almighty-core/events","assignees_url":"https://api.github.com/repos/almighty/almighty-core/assignees{/user}","branches_url":"https://api.github.com/repos/almighty/almighty-core/branches{/branch}","tags_url":"https://api.github.com/repos/almighty/almighty-core/tags","blobs_url":"https://api.github.com/repos/almighty/almighty-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/almighty/almighty-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/almighty/almighty-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/almighty/almighty-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/almighty/almighty-core/statuses/{sha}","languages_url":"https://api.github.com/repos/almighty/almighty-core/languages","stargazers_url":"https://api.github.com/repos/almighty/almighty-core/stargazers","contributors_url":"https://api.github.com/repos/almighty/almighty-core/contributors","subscribers_url":"https://api.github.com/repos/almighty/almighty-core/subscribers","subscription_url":"https://api.github.com/repos/almighty/almighty-core/subscription","commits_url":"https://api.github.com/repos/almighty/almighty-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/almighty/almighty-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/almighty/almighty-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/almighty/almighty-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/almighty/almighty-core/contents/{+path}","compare_url":"https://api.github.com/repos/almighty/almighty-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/almighty/almighty-core/merges","archive_url":"https://api.github.com/repos/almighty/almighty-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/almighty/almighty-core/downloads","issues_url":"https://api.github.com/repos/almighty/almighty-core/issues{/number}","pulls_url":"https://api.github.com/repos/almighty/almighty-core/pulls{/number}","milestones_url":"https://api.github.com/repos/almighty/almighty-core/milestones{/number}","notifications_url":"https://api.github.com/repos/almighty/almighty-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/almighty/almighty-core/labels{/name}","releases_url":"https://api.github.com/repos/almighty/almighty-core/releases{/id}","deployments_url":"https://api.github.com/repos/almighty/almighty-core/deployments","created_at":"2016-03-19T10:42:15Z","updated_at":"2016-09-21T20:02:55Z","pushed_at":"2016-09-27T13:41:32Z","git_url":"git://github.com/almighty/almighty-core.git","ssh_url":"git@github.com:almighty/almighty-core.git","clone_url":"https://github.com/almighty/almighty-core.git","svn_url":"https://github.com/almighty/almighty-core","homepage":"http://devdoc.almighty.io/","size":4694,"stargazers_count":12,"watchers_count":12,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":27,"mirror_url":null,"open_issues_count":81,"forks":27,"open_issues":81,"watchers":12,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/almighty/almighty-core/pulls/278"},"html":{"href":"https://github.com/almighty/almighty-core/pull/278"},"issue":{"href":"https://api.github.com/repos/almighty/almighty-core/issues/278"},"comments":{"href":"https://api.github.com/repos/almighty/almighty-core/issues/278/comments"},"review_comments":{"href":"https://api.github.com/repos/almighty/almighty-core/pulls/278/comments"},"review_comment":{"href":"https://api.github.com/repos/almighty/almighty-core/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/almighty/almighty-core/pulls/278/commits"},"statuses":{"href":"https://api.github.com/repos/almighty/almighty-core/statuses/e43b2a0c2e2adee271452c8e68b3039011b4a30a"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":2,"review_comments":12,"commits":3,"additions":159,"deletions":12,"changed_files":7}}
{"actor":{"display_login":"aslakknutsen"}}