diff --git a/main.go b/main.go index c2d24d0..c42aced 100644 --- a/main.go +++ b/main.go @@ -57,7 +57,7 @@ func main() { relativeN := flag.Arg(1) relativeNInt, err := strconv.Atoi(relativeN) if err != nil { - fmt.Println("Unable to parse parse param .") + fmt.Println("Unable to parse param .") os.Exit(1) } timerStart = time.Now() @@ -66,6 +66,29 @@ func main() { writePipe(pipe) printTimer() + case "goto": + verifyMigrationsPath(*migrationsPath) + toVerion := flag.Arg(1) + toVerionInt, err := strconv.Atoi(toVerion) + if err != nil || toVerionInt < 0 { + fmt.Println("Unable to parse param .") + os.Exit(1) + } + + currentVersion, err := migrate.Version(*url, *migrationsPath) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + relativeNInt := toVerionInt - int(currentVersion) + + timerStart = time.Now() + pipe := pipep.New() + go migrate.Migrate(pipe, *url, *migrationsPath, relativeNInt) + writePipe(pipe) + printTimer() + case "up": verifyMigrationsPath(*migrationsPath) timerStart = time.Now() @@ -181,6 +204,7 @@ Commands: redo Roll back most recent migration, then apply it again version Show current migration version migrate Apply migrations -n|+n + goto Migrate to version v help Show this help '-path' defaults to current working directory.