mirror of
https://github.com/therootcompany/golib.git
synced 2026-04-24 20:58:00 +00:00
fix(sql-migrate): reject explicit 'up 0' as invalid
An explicit 0 argument to 'up' should error (like 'down 0' already does), not silently run all pending migrations. Change the guard from < 0 to < 1 to match 'down' behavior.
This commit is contained in:
parent
40fa1e876c
commit
03d81a2b76
@ -344,10 +344,10 @@ func main() {
|
|||||||
var upN int
|
var upN int
|
||||||
switch len(leafArgs) {
|
switch len(leafArgs) {
|
||||||
case 0:
|
case 0:
|
||||||
// ignore
|
// no arg: upN stays 0, meaning "all pending"
|
||||||
case 1:
|
case 1:
|
||||||
upN, err = strconv.Atoi(leafArgs[0])
|
upN, err = strconv.Atoi(leafArgs[0])
|
||||||
if err != nil || upN < 0 {
|
if err != nil || upN < 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