From e3112d5a4fd5bfe1164fa90c8740ad63a027a5b1 Mon Sep 17 00:00:00 2001 From: Liam Staskawicz Date: Sun, 23 Dec 2012 17:51:49 -0800 Subject: [PATCH] migrate: validate that given migrations don't have ID 0 --- migrate.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/migrate.go b/migrate.go index 4f1abbe..7a2a624 100644 --- a/migrate.go +++ b/migrate.go @@ -189,7 +189,13 @@ func numericComponent(name string) (int, error) { if idx < 0 { return 0, errors.New("no separator found") } - return strconv.Atoi(base[:idx]) + + n, e := strconv.Atoi(base[:idx]) + if e == nil && n == 0 { + return 0, errors.New("0 is not a valid migration ID") + } + + return n, e } // retrieve the current version for this DB.