mirror of
https://github.com/therootcompany/golib.git
synced 2026-04-24 20:58:00 +00:00
fix(sql-migrate): reject explicit 'up 0' and 'down 0' as invalid
An explicit 0 argument should error, not silently run all pending (up) or get handled as a special case (down). Change the guard from < 0 to < 1 in both subcommands so '0' is treated as invalid input.
This commit is contained in:
parent
03d81a2b76
commit
2080ae223d
@ -364,10 +364,10 @@ func main() {
|
|||||||
var downN int
|
var downN int
|
||||||
switch len(leafArgs) {
|
switch len(leafArgs) {
|
||||||
case 0:
|
case 0:
|
||||||
// ignore
|
// default: roll back one
|
||||||
case 1:
|
case 1:
|
||||||
downN, err = strconv.Atoi(leafArgs[0])
|
downN, err = strconv.Atoi(leafArgs[0])
|
||||||
if err != nil || downN < 0 {
|
if err != nil || downN < 1 {
|
||||||
fmt.Fprintf(os.Stderr, "Error: %s is not a positive number\n", leafArgs[0])
|
fmt.Fprintf(os.Stderr, "Error: %s is not a positive number\n", leafArgs[0])
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user