From 34503e3668a8ac118c31d9bdcdb4092548c12f68 Mon Sep 17 00:00:00 2001 From: Ty Eggen Date: Sun, 1 Dec 2024 21:11:20 +0000 Subject: [PATCH] tools: improved version error handling for tools/create-sql-migration.sh --- tools/create-sql-migration.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/create-sql-migration.sh b/tools/create-sql-migration.sh index f30870ce..9b41bb67 100755 --- a/tools/create-sql-migration.sh +++ b/tools/create-sql-migration.sh @@ -20,6 +20,14 @@ TS=$(node -e 'console.log(Date.now())') VERSION="$1" +if [ "${VERSION}" != "new" ] && [ "$(echo "${VERSION}" | grep -E '[0-9]+')" = "" ]; then + echo "ERROR: specified version is not a valid migration id" + echo "" + echo "$(basename "$0") " + + exit 254 +fi + if [ "${VERSION}" = "new" ]; then VERSION=$(find migrations/ -mindepth 1 -maxdepth 1 -type d -print0 | xargs -0 -n 1 basename | sort -V | tail -1 | awk '{ print $1 + 1 }') fi