github.com/anovateam/migrate@v3.5.4+incompatible/source/go_bindata/README.md (about)

     1  # go_bindata
     2  
     3  ## Usage
     4  
     5  
     6  
     7  ### Read bindata with NewWithSourceInstance
     8  
     9  ```shell
    10  go get -u github.com/jteeuwen/go-bindata/...
    11  cd examples/migrations && go-bindata -pkg migrations .
    12  ```
    13  
    14  ```go
    15  import (
    16    "github.com/golang-migrate/migrate"
    17    "github.com/golang-migrate/migrate/source/go_bindata"
    18    "github.com/golang-migrate/migrate/source/go_bindata/examples/migrations"
    19  )
    20  
    21  func main() {
    22    // wrap assets into Resource
    23    s := bindata.Resource(migrations.AssetNames(),
    24      func(name string) ([]byte, error) {
    25        return migrations.Asset(name)
    26      })
    27      
    28    d, err := bindata.WithInstance(s)
    29    m, err := migrate.NewWithSourceInstance("go-bindata", d, "database://foobar")
    30    m.Up() // run your migrations and handle the errors above of course
    31  }
    32  ```
    33  
    34  ### Read bindata with URL (todo)
    35  
    36  This will restore the assets in a tmp directory and then
    37  proxy to source/file. go-bindata must be in your `$PATH`.
    38  
    39  ```
    40  migrate -source go-bindata://examples/migrations/bindata.go
    41  ```
    42  
    43