{"action":"created","issue":{"url":"https://api.github.com/repos/fabric8-services/fabric8-common/issues/21","repository_url":"https://api.github.com/repos/fabric8-services/fabric8-common","labels_url":"https://api.github.com/repos/fabric8-services/fabric8-common/issues/21/labels{/name}","comments_url":"https://api.github.com/repos/fabric8-services/fabric8-common/issues/21/comments","events_url":"https://api.github.com/repos/fabric8-services/fabric8-common/issues/21/events","html_url":"https://github.com/fabric8-services/fabric8-common/pull/21","id":368057776,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIxMzIxMDEy","number":21,"title":"Added DB migration package","user":{"login":"nurali-techie","id":35909407,"node_id":"MDQ6VXNlcjM1OTA5NDA3","avatar_url":"https://avatars0.githubusercontent.com/u/35909407?v=4","gravatar_id":"","url":"https://api.github.com/users/nurali-techie","html_url":"https://github.com/nurali-techie","followers_url":"https://api.github.com/users/nurali-techie/followers","following_url":"https://api.github.com/users/nurali-techie/following{/other_user}","gists_url":"https://api.github.com/users/nurali-techie/gists{/gist_id}","starred_url":"https://api.github.com/users/nurali-techie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nurali-techie/subscriptions","organizations_url":"https://api.github.com/users/nurali-techie/orgs","repos_url":"https://api.github.com/users/nurali-techie/repos","events_url":"https://api.github.com/users/nurali-techie/events{/privacy}","received_events_url":"https://api.github.com/users/nurali-techie/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":12,"created_at":"2018-10-09T06:24:54Z","updated_at":"2018-10-16T05:06:30Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/fabric8-services/fabric8-common/pulls/21","html_url":"https://github.com/fabric8-services/fabric8-common/pull/21","diff_url":"https://github.com/fabric8-services/fabric8-common/pull/21.diff","patch_url":"https://github.com/fabric8-services/fabric8-common/pull/21.patch"},"body":"**How to use:**\r\n\r\nassuming fabric8-env service wants to re-use Migration functionality from f8-common.\r\n\r\nfabric8-env would be having below tree project structure for migration:\r\n```\r\nmain.go\r\nmigration\r\n├── migration.go\r\n├── sqlbindata.go\r\n└── sql-files\r\n    ├── 000-bootstrap.sql\r\n    └── 001-environments.sql\r\n```\r\nNow, the content of `fabric8-env/migration/migration.go` would be:\r\n\r\n```\r\npackage migration\r\n\r\nimport \"database/sql\"\r\nimport \"github.com/fabric8-services/fabric8-common/migration\"\r\n\r\ntype migrateData struct {\r\n}\r\n\r\nfunc Migrate(db *sql.DB, catalog string) error {\r\n\treturn migration.Migrate(db, catalog, migrateData{})\r\n}\r\n\r\nfunc (d migrateData) Asset(name string) ([]byte, error) {\r\n\treturn Asset(name)\r\n}\r\n\r\nfunc (d migrateData) AssetNameWithArgs() [][]string {\r\n\tnameWithArgs := [][]string{\r\n\t\t{\"000-bootstrap.sql\"},\r\n\t\t{\"001-environments.sql\", \"cluster1.com\"},\r\n\t}\r\n\treturn nameWithArgs\r\n}\r\n```\r\n.. and call from `main.go` would be same as before:\r\n```\r\nerr = migration.Migrate(db.DB(), config.GetPostgresDatabase())\r\nif err != nil {\r\n\tlog.Panic(nil, map[string]interface{}{\"err\": err},\r\n\t\t\"failed migration\")\r\n}\r\n```\r\n\r\nSo flow would be ..\r\nmain.go -> call fabric8-env/migration.Migrate -> call fabric8-common/migration.Migrate(migrateData)\r\n\r\nTODO:\r\n- [x] tests"},"comment":{"url":"https://api.github.com/repos/fabric8-services/fabric8-common/issues/comments/430102275","html_url":"https://github.com/fabric8-services/fabric8-common/pull/21#issuecomment-430102275","issue_url":"https://api.github.com/repos/fabric8-services/fabric8-common/issues/21","id":430102275,"node_id":"MDEyOklzc3VlQ29tbWVudDQzMDEwMjI3NQ==","user":{"login":"nurali-techie","id":35909407,"node_id":"MDQ6VXNlcjM1OTA5NDA3","avatar_url":"https://avatars0.githubusercontent.com/u/35909407?v=4","gravatar_id":"","url":"https://api.github.com/users/nurali-techie","html_url":"https://github.com/nurali-techie","followers_url":"https://api.github.com/users/nurali-techie/followers","following_url":"https://api.github.com/users/nurali-techie/following{/other_user}","gists_url":"https://api.github.com/users/nurali-techie/gists{/gist_id}","starred_url":"https://api.github.com/users/nurali-techie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nurali-techie/subscriptions","organizations_url":"https://api.github.com/users/nurali-techie/orgs","repos_url":"https://api.github.com/users/nurali-techie/repos","events_url":"https://api.github.com/users/nurali-techie/events{/privacy}","received_events_url":"https://api.github.com/users/nurali-techie/received_events","type":"User","site_admin":false},"created_at":"2018-10-16T05:06:30Z","updated_at":"2018-10-16T05:06:30Z","author_association":"CONTRIBUTOR","body":"@alexeykazakov \r\n> The same compilation error if run `make test-integration-no-coverage`\r\n\r\nDone [9aec06c](https://github.com/fabric8-services/fabric8-common/pull/21/commits/9aec06c36d89c711e8877f4531eb5d33bca616cd)"}}
{"actor":{"display_login":"nurali-techie"}}