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:
AJ ONeal 2026-04-08 14:38:05 -06:00
parent 40fa1e876c
commit 03d81a2b76
No known key found for this signature in database

View File

@ -344,10 +344,10 @@ func main() {
var upN int
switch len(leafArgs) {
case 0:
// ignore
// no arg: upN stays 0, meaning "all pending"
case 1:
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])
os.Exit(1)
}