migrate/source/go-bindata
Dale Hui 1cf095c51d Update more references to github.com/mattes/migrate 2018-01-19 14:59:27 -08:00
..
examples/migrations initial version 3.0.0 preview 2017-02-07 22:01:29 -08:00
testdata initial version 3.0.0 preview 2017-02-07 22:01:29 -08:00
README.md Update more references to github.com/mattes/migrate 2018-01-19 14:59:27 -08:00
go-bindata.go Update imports to reference fork. 2018-01-19 10:56:55 -08:00
go-bindata_test.go Update imports to reference fork. 2018-01-19 10:56:55 -08:00

README.md

go-bindata

Usage

Read bindata with NewWithSourceInstance

go get -u github.com/jteeuwen/go-bindata/...
cd examples/migrations && go-bindata -pkg migrations .
import (
  "github.com/golang-migrate/migrate"
  "github.com/golang-migrate/migrate/source/go-bindata"
  "github.com/golang-migrate/migrate/source/go-bindata/examples/migrations"
)

func main() {
  // wrap assets into Resource
  s := bindata.Resource(migrations.AssetNames(),
    func(name string) ([]byte, error) {
      return migrations.Asset(name)
    })
    
  d, err := bindata.WithInstance(s)
  m, err := migrate.NewWithSourceInstance("go-bindata", d, "database://foobar")
  m.Up() // run your migrations and handle the errors above of course
}

Read bindata with URL (todo)

This will restore the assets in a tmp directory and then proxy to source/file. go-bindata must be in your $PATH.

migrate -source go-bindata://examples/migrations/bindata.go