DB versioning fixes
gitea/salix/dev There was a failure building this commit Details

This commit is contained in:
Juan Ferrer 2019-04-08 09:38:38 +02:00
parent d0dc192fc4
commit f46d50fc48
2 changed files with 9 additions and 6 deletions

View File

@ -3,9 +3,6 @@
ALTER TABLE `vn`.`itemTaxCountry` AUTO_INCREMENT = 1;
ALTER TABLE `vn2008`.`Consignatarios` AUTO_INCREMENT = 1;
INSERT INTO `util`.`config` ( `dbVersion`, `hasTriggersDisabled`, `environment`)
VALUES ('1.0.0', '0', 'development');
INSERT INTO `vn`.`ticketConfig` (`id`, `scopeDays`)
VALUES
('1', '6');

View File

@ -78,7 +78,6 @@ fi
# Applying changes
N_CHANGES=0
echo "[INFO] Applying changes."
for DIR_PATH in "$DIR/changes/"*; do
DIR_NAME=$(basename $DIR_PATH)
@ -96,7 +95,14 @@ for DIR_PATH in "$DIR/changes/"*; do
echo "[INFO] Applying version: $DIR_NAME"
for FILE in "$DIR_PATH/"*; do
echo "[INFO] -> $(basename "$FILE")"
FILE_NAME=$(basename "$FILE")
if [[ ! "$FILE_NAME" =~ ^[0-9]{2}-[a-zA-Z0-9]+\.sql$ ]]; then
echo "[WARN] Ignoring wrong file name: $FILE_NAME"
continue
fi
echo "[INFO] -> $FILE_NAME"
mysql --defaults-file="$INI_FILE" --comments < $FILE
N_CHANGES=$((N_CHANGES + 1))
done
@ -106,7 +112,7 @@ for DIR_PATH in "$DIR/changes/"*; do
done
if [ "$N_CHANGES" -eq "0" ]; then
echo "[INFO] No changes to apply."
echo "[INFO] No changes applied."
else
echo "[INFO] Changes applied succesfully."
fi