github.com/dannyzhou2015/migrate/v4@v4.15.2/source/pkger/README.md (about)

     1  # pkger
     2  ```go
     3  package main
     4  
     5  import (
     6  	"errors"
     7  	"log"
     8  
     9  	"github.com/dannyzhou2015/migrate/v4"
    10  	"github.com/markbates/pkger"
    11  
    12  	_ "github.com/dannyzhou2015/migrate/v4/database/postgres"
    13  	_ "github.com/dannyzhou2015/migrate/v4/source/pkger"
    14  	_ "github.com/lib/pq"
    15  )
    16  
    17  func main() {
    18  	pkger.Include("/module/path/to/migrations")
    19  	m, err := migrate.New("pkger:///module/path/to/migrations", "postgres://postgres@localhost/postgres?sslmode=disable")
    20  	if err != nil {
    21  		log.Fatalln(err)
    22  	}
    23  	if err := m.Up(); errors.Is(err, migrate.ErrNoChange) {
    24  		log.Println(err)
    25  	} else if err != nil {
    26  		log.Fatalln(err)
    27  	}
    28  }
    29  ```