-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.go
34 lines (28 loc) · 898 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package main
import (
"flag"
"log"
migrate "github.com/lawzava/go-pg-migrate/v2"
)
func main() {
var opt migrate.Options
flag.StringVar(&opt.DatabaseURI, "database-uri", "postgres://postgres@localhost:5432/migrate-test",
"database uri to connect to")
flag.UintVar(&opt.VersionNumberToApply, "version", 0,
"migrate to specified printVersion; 0 will apply all forward migrations")
flag.BoolVar(&opt.PrintInfoAndExit, "current", false,
"print last applied version and exit")
flag.BoolVar(&opt.ForceVersionWithoutMigrations, "force", false,
"force version of migration to set in database without running any migrations")
flag.BoolVar(&opt.RefreshSchema, "refresh", false,
"refresh database, should be set for first run (when DB is empty)")
flag.Parse()
m, err := migrate.New(opt)
if err != nil {
log.Fatal(err)
}
err = m.Migrate()
if err != nil {
log.Fatal(err)
}
}