goose
goose copied to clipboard
[WIP] - Adding a provider
I don't intend to merge this branch, simply putting up a PR to show where my thinking is at.
This may be done in a backwards-compatible way, since the entry point to a well-defined struct is goose.NewProvider.
I'll go into more detail (eventually), but the summary is:
- Add a well-defined
Providerstruct that can be initizlied independently. No more global state, allowing multiple providers per runtime - All methods that apply migrations now support
context.Context - Decouple dialect from driver name. I think the user should pass a
*sql.DBand use whatever driver they want, they just have to match it to one of the supported dialects - Move CLI concerns to the CLI, and move package concerns to the package. E.g., the goose library should not log so much as a library
- Add support for Go functions that accept
*sql.DB - ... add more
// GoMigration is a go migration func that is run within a transaction.
type GoMigration func(tx *sql.Tx) error
// GoMigrationNoTx is a go migration funt that is run outside a transaction.
type GoMigrationNoTx func(db *sql.DB) error