From 88b1881d22156457c28f83433d51b0cf60e4e615 Mon Sep 17 00:00:00 2001 From: Yehonal Date: Tue, 30 Aug 2016 15:41:59 +0200 Subject: [BASH/DB] Fixed importing script with revisioned sql --- bin/db_pendings/import.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'bin') diff --git a/bin/db_pendings/import.sh b/bin/db_pendings/import.sh index cf85cd349e..5ee63a0f65 100755 --- a/bin/db_pendings/import.sh +++ b/bin/db_pendings/import.sh @@ -51,11 +51,14 @@ function import() { suffix=${oldFile#rev_} rev=${suffix%.sql} - [[ $prefix = "rev" && $suffix =~ ^-?[0-9]+$ ]] && isRev=1 || isRev=0 + isRev=0 + if [[ $prefix = "rev" && $rev =~ ^-?[0-9]+$ ]]; then + isRev=1 + fi echo "-- DB update $oldVer -> $newVer" > "$newFile"; - if [[ $isRev ]]; then + if [[ $isRev -eq 1 ]]; then echo "DROP PROCEDURE IF EXISTS \`updateDb\`;" >> "$newFile"; echo "DELIMITER //" >> "$newFile"; echo "CREATE PROCEDURE updateDb ()" >> "$newFile"; @@ -65,7 +68,7 @@ function import() { echo "$startTransaction" >> "$newFile"; echo "$updHeader" >> "$newFile"; - if [[ $isRev ]]; then + if [[ $isRev -eq 1 ]]; then echo "SELECT sql_rev INTO OK FROM version_db_"$db" WHERE sql_rev = '$rev'; IF OK <> 'FALSE' THEN LEAVE proc; END IF;" >> "$newFile"; fi; @@ -81,7 +84,7 @@ function import() { echo "$endTransaction" >> "$newFile"; - if [[ $isRev ]]; then + if [[ $isRev -eq 1 ]]; then echo "END;" >> "$newFile"; echo "//" >> "$newFile"; echo "DELIMITER ;" >> "$newFile"; -- cgit v1.2.3