migrate/source/go_bindata
Dale Hui fc2b2e9c64 Use v4 for Go module support 2018-10-10 16:16:23 -07:00
..
examples/migrations Rename sources to reflect updated build constraint names 2018-06-12 16:45:56 +08:00
testdata Rename sources to reflect updated build constraint names 2018-06-12 16:45:56 +08:00
README.md Use v4 for Go module support 2018-10-10 16:16:23 -07:00
go-bindata.go Use v4 for Go module support 2018-10-10 16:16:23 -07:00
go-bindata_test.go Use v4 for Go module support 2018-10-10 16:16:23 -07: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/v4"
  "github.com/golang-migrate/migrate/v4/source/go_bindata"
  "github.com/golang-migrate/migrate/v4/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