DB versioning fixes
This commit is contained in:
parent
479b4c68c8
commit
a12ef2c290
|
@ -43,7 +43,7 @@ if [ "$ENV" == "production" ]; then
|
|||
|
||||
if [ "$ANSWER" != "yes" ]; then
|
||||
echo "[INFO] Aborting changes."
|
||||
exit;
|
||||
exit
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
@ -57,7 +57,7 @@ else
|
|||
fi
|
||||
|
||||
if [ ! -f "$INI_FILE" ]; then
|
||||
echo "[ERROR] Config file doesn't exists: $INI_FILE"
|
||||
echo "[ERROR] Config file doesn't exists: $INI_FILE"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
|
@ -83,18 +83,25 @@ echo "[INFO] Applying changes."
|
|||
for VERSION_DIR in "$DIR/changes/"*; do
|
||||
DIR_VERSION=$(basename $VERSION_DIR)
|
||||
|
||||
if [ "$DB_VERSION" -lt "$DIR_VERSION" ]; then
|
||||
echo "[INFO] Applying version: $DIR_VERSION"
|
||||
|
||||
for FILE in "$VERSION_DIR/"*; do
|
||||
echo "[INFO] -> $(basename "$FILE")"
|
||||
mysql --defaults-file="$INI_FILE" --comments < $FILE
|
||||
N_CHANGES=$((N_CHANGES + 1))
|
||||
done
|
||||
|
||||
UPDATE_VERSION="UPDATE util.config SET dbVersion='$DIR_VERSION'"
|
||||
echo "$UPDATE_VERSION" | mysql --defaults-file="$INI_FILE"
|
||||
if [[ ! "$DIR_VERSION" =~ ^[0-9]{5}$ ]]; then
|
||||
echo "[INFO] Ignoring wrong version number: $DIR_VERSION"
|
||||
continue
|
||||
fi
|
||||
if [ "$DB_VERSION" -ge "$DIR_VERSION" ]; then
|
||||
echo "[INFO] Ignoring already applied version: $DIR_VERSION"
|
||||
continue
|
||||
fi
|
||||
|
||||
echo "[INFO] Applying version: $DIR_VERSION"
|
||||
|
||||
for FILE in "$VERSION_DIR/"*; do
|
||||
echo "[INFO] -> $(basename "$FILE")"
|
||||
mysql --defaults-file="$INI_FILE" --comments < $FILE
|
||||
N_CHANGES=$((N_CHANGES + 1))
|
||||
done
|
||||
|
||||
UPDATE_VERSION="UPDATE util.config SET dbVersion='$DIR_VERSION'"
|
||||
echo "$UPDATE_VERSION" | mysql --defaults-file="$INI_FILE"
|
||||
done
|
||||
|
||||
if [ "$N_CHANGES" -eq "0" ]; then
|
||||
|
|
Loading…
Reference in New Issue