Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7b58ded

Browse files
committed
source/pkger: add readme
1 parent 3c71508 commit 7b58ded

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

source/pkger/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# pkger
2+
```
3+
package main
4+
5+
import (
6+
"errors"
7+
"log"
8+
9+
"github.com/golang-migrate/migrate/v4"
10+
"github.com/markbates/pkger"
11+
12+
_ "github.com/golang-migrate/migrate/v4/database/postgres"
13+
_ "github.com/golang-migrate/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+
```

0 commit comments

Comments
 (0)