From 2080ae223d1f041402c843bb85bb26c4aa88720e Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Wed, 8 Apr 2026 14:54:28 -0600 Subject: [PATCH] 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. --- cmd/sql-migrate/main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/sql-migrate/main.go b/cmd/sql-migrate/main.go index a38be93..3b3daad 100644 --- a/cmd/sql-migrate/main.go +++ b/cmd/sql-migrate/main.go @@ -364,10 +364,10 @@ func main() { var downN int switch len(leafArgs) { case 0: - // ignore + // default: roll back one case 1: 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]) os.Exit(1) }