import "github.com/joncalhoun/migrate"
type Sqlx struct { Migrations []SqlxMigration // Printf is used to print out additional information during a migration, such // as which step the migration is currently on. It can be replaced with any // custom printf function, including one that just ignores inputs. If nil it // will default to fmt.Printf. Printf func(format string, a ...interface{}) (n int, err error) }
Sqlx is a migrator that uses github.com/jmoiron/sqlx
Migrate will run the migrations using the provided db connection.
Rollback will run all rollbacks using the provided db connection.
type SqlxMigration struct { ID string Migrate func(tx *sqlx.Tx) error Rollback func(tx *sqlx.Tx) error }
SqlxMigration is a unique ID plus a function that uses a sqlx transaction to perform a database migration step.
Note: Long term this could have a Rollback field if we wanted to support that.
func SqlxFileMigration(id, upFile, downFile string) SqlxMigration
SqlxFileMigration will create a SqlxMigration using the provided file.
func SqlxQueryMigration(id, upQuery, downQuery string) SqlxMigration
SqlxQueryMigration will create a SqlxMigration using the provided id and query string. It is a helper function designed to simplify the process of creating migrations that only depending on a SQL query string.
Package migrate imports 5 packages (graph). Updated 2020-09-16. Refresh now. Tools for package owners.