DB versioning fixes
This commit is contained in:
parent
4847c6552b
commit
b7092d97d3
|
@ -80,21 +80,22 @@ fi
|
|||
N_CHANGES=0
|
||||
echo "[INFO] Applying changes."
|
||||
|
||||
for VERSION_DIR in "$DIR/changes/"*; do
|
||||
DIR_VERSION=$(basename $VERSION_DIR)
|
||||
for DIR_PATH in "$DIR/changes/"*; do
|
||||
DIR_NAME=$(basename $DIR_PATH)
|
||||
DIR_VERSION=${DIR_NAME:0:5}
|
||||
|
||||
if [[ ! "$DIR_VERSION" =~ ^[0-9]{5}$ ]]; then
|
||||
echo "[INFO] Ignoring wrong version number: $DIR_VERSION"
|
||||
if [[ ! "$DIR_NAME" =~ ^[0-9]{5}(-[a-zA-Z0-9]+)?$ ]]; then
|
||||
echo "[WARN] Ignoring wrong directory name: $DIR_NAME"
|
||||
continue
|
||||
fi
|
||||
if [ "$DB_VERSION" -ge "$DIR_VERSION" ]; then
|
||||
echo "[INFO] Ignoring already applied version: $DIR_VERSION"
|
||||
echo "[INFO] Ignoring already applied version: $DIR_NAME"
|
||||
continue
|
||||
fi
|
||||
|
||||
echo "[INFO] Applying version: $DIR_VERSION"
|
||||
echo "[INFO] Applying version: $DIR_NAME"
|
||||
|
||||
for FILE in "$VERSION_DIR/"*; do
|
||||
for FILE in "$DIR_PATH/"*; do
|
||||
echo "[INFO] -> $(basename "$FILE")"
|
||||
mysql --defaults-file="$INI_FILE" --comments < $FILE
|
||||
N_CHANGES=$((N_CHANGES + 1))
|
||||
|
@ -106,5 +107,7 @@ done
|
|||
|
||||
if [ "$N_CHANGES" -eq "0" ]; then
|
||||
echo "[INFO] No changes to apply."
|
||||
else
|
||||
echo "[INFO] Changes applied succesfully."
|
||||
fi
|
||||
|
||||
|
|
Loading…
Reference in New Issue