2017-02-07 22:01:29 -08:00
|
|
|
# go-bindata
|
|
|
|
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
go get -u github.com/jteeuwen/go-bindata/...
|
|
|
|
cd examples/migrations && go-bindata -pkg migrations .
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
// 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
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
import (
|
|
|
|
"github.com/mattes/migrate"
|
|
|
|
"github.com/mattes/migrate/source/go-bindata"
|
|
|
|
"github.com/mattes/migrate/source/go-bindata/examples/migrations
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2017-02-07 22:59:12 -08:00
|
|
|
// wrap assets into Resource
|
|
|
|
s := bindata.Resource(migrations.AssetNames(),
|
2017-02-07 22:01:29 -08:00
|
|
|
func(name string) ([]byte, error) {
|
|
|
|
return migrations.Asset(name)
|
|
|
|
})
|
|
|
|
|
2017-02-07 23:00:25 -08:00
|
|
|
m, err := migrate.NewWithSourceInstance("go-bindata", s, "database://foobar")
|
2017-02-07 22:01:29 -08:00
|
|
|
m.Up() // run your migrations and handle the errors above of course
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|