mirror of
https://github.com/hanzoai/migrate.git
synced 2026-09-30 22:55:10 +00:00
go fix applied the modernizers. One rewrite it got wrong is corrected here: a reverse loop over runes became a range over slices.Backward that bound the index and the value to the SAME name, which does not compile and would have compared a rune to an index if it had. The value gets its own name. Co-authored-by: Hanzo Dev <[email protected]>
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