Packr backed driver for golang-migrate
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
driver
vendor/github.com
Gopkg.lock
Gopkg.toml
README.md

README.md

packr-source-driver

Use gobuffalo/packr to bundle database migrations in the final binary and use them as a source to golang-migrate/migrate.

Usage

Here's a simple example of how to create a migrate instance with a packr based driver:

import (
	"fmt"
	packrdriver "github.com/fiskeben/packr-source-driver/driver"
	"github.com/gobuffalo/packr"
	"github.com/golang-migrate/migrate"
)

func makeMigrate(connection string) (*migrate.Migrate, error) {
	box := packr.NewBox("./path/to/migration/steps")
	driver, err := packrdriver.WithInstance(box)
	if err != nil {
		return nil, fmt.Errorf("failed to create migration data driver: %v", err)
	}

	return migrate.NewWithSourceInstance("packr", driver, connection)
}

Contribute

PRs are welcome.