DB versioning fixes
This commit is contained in:
parent
479b4c68c8
commit
a12ef2c290
|
@ -43,7 +43,7 @@ if [ "$ENV" == "production" ]; then
|
||||||
|
|
||||||
if [ "$ANSWER" != "yes" ]; then
|
if [ "$ANSWER" != "yes" ]; then
|
||||||
echo "[INFO] Aborting changes."
|
echo "[INFO] Aborting changes."
|
||||||
exit;
|
exit
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -57,7 +57,7 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f "$INI_FILE" ]; then
|
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
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -83,18 +83,25 @@ echo "[INFO] Applying changes."
|
||||||
for VERSION_DIR in "$DIR/changes/"*; do
|
for VERSION_DIR in "$DIR/changes/"*; do
|
||||||
DIR_VERSION=$(basename $VERSION_DIR)
|
DIR_VERSION=$(basename $VERSION_DIR)
|
||||||
|
|
||||||
if [ "$DB_VERSION" -lt "$DIR_VERSION" ]; then
|
if [[ ! "$DIR_VERSION" =~ ^[0-9]{5}$ ]]; then
|
||||||
echo "[INFO] Applying version: $DIR_VERSION"
|
echo "[INFO] Ignoring wrong version number: $DIR_VERSION"
|
||||||
|
continue
|
||||||
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"
|
|
||||||
fi
|
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
|
done
|
||||||
|
|
||||||
if [ "$N_CHANGES" -eq "0" ]; then
|
if [ "$N_CHANGES" -eq "0" ]; then
|
||||||
|
|
Loading…
Reference in New Issue