migrate
migrate copied to clipboard
Pass context to database drivers
This PR adds support for passing a context to database drivers. I've added migrate.NewWithContext() and migrate.NewWithSourceContext() which accept a context. For each driver, I've added OpenWithContext and WithInstanceContext which will pass the context to the database during any initial connection. This handles https://github.com/golang-migrate/migrate/issues/571.
Pull Request Test Coverage Report for Build 1359990807
- 228 of 275 (82.91%) changed or added relevant lines in 18 files are covered.
- 7 unchanged lines in 7 files lost coverage.
- Overall coverage increased (+1.04%) to 58.734%
| Changes Missing Coverage | Covered Lines | Changed/Added Lines | % |
|---|---|---|---|
| database/cassandra/cassandra.go | 8 | 10 | 80.0% |
| database/firebird/firebird.go | 9 | 11 | 81.82% |
| database/mysql/mysql.go | 10 | 12 | 83.33% |
| database/spanner/spanner.go | 10 | 12 | 83.33% |
| database/sqlserver/sqlserver.go | 11 | 13 | 84.62% |
| database/cockroachdb/cockroachdb.go | 14 | 17 | 82.35% |
| database/redshift/redshift.go | 10 | 13 | 76.92% |
| database/stub/stub.go | 11 | 26 | 42.31% |
| migrate.go | 32 | 48 | 66.67% |
| <!-- | Total: | 228 | 275 |
| Files with Coverage Reduction | New Missed Lines | % |
|---|---|---|
| database/cassandra/cassandra.go | 1 | 47.37% |
| database/cockroachdb/cockroachdb.go | 1 | 62.98% |
| database/firebird/firebird.go | 1 | 75.58% |
| database/mysql/mysql.go | 1 | 64.74% |
| database/redshift/redshift.go | 1 | 67.86% |
| database/spanner/spanner.go | 1 | 69.51% |
| database/sqlserver/sqlserver.go | 1 | 70.08% |
| <!-- | Total: | 7 |
| Totals | |
|---|---|
| Change from base Build 1346768578: | 1.04% |
| Covered Lines: | 3880 |
| Relevant Lines: | 6606 |
💛 - Coveralls
hey i'd love to see this change merged are their any blockers (apart from it being out of date with master)?
Thanks for the PR!
hey i'd love to see this change merged are their any blockers (apart from it being out of date with master)?
Sorry I need to find time to review this :( I'll try to get to it during the holidays.