migrate: github.com/joncalhoun/migrate Index | Files

package migrate

import "github.com/joncalhoun/migrate"


Package Files


type Sqlx Uses

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

func (*Sqlx) Migrate Uses

func (s *Sqlx) Migrate(sqlDB *sql.DB, dialect string) error

Migrate will run the migrations using the provided db connection.

func (*Sqlx) Rollback Uses

func (s *Sqlx) Rollback(sqlDB *sql.DB, dialect string) error

Rollback will run all rollbacks using the provided db connection.

type SqlxMigration Uses

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 Uses

func SqlxFileMigration(id, upFile, downFile string) SqlxMigration

SqlxFileMigration will create a SqlxMigration using the provided file.

func SqlxQueryMigration Uses

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.