Update 01-migrations

Fix broken bash syntax
pull/109/head
Eric Nemchik 2022-08-22 09:15:44 -05:00 zatwierdzone przez GitHub
rodzic 5f4069843a
commit b32a18a6ae
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 9 dodań i 9 usunięć

Wyświetl plik

@ -5,25 +5,25 @@ MIGRATIONS_HISTORY="/config/.migrations"
echo "[migrations] started" echo "[migrations] started"
if [ ! -d $MIGRATIONS_DIR ]; then if [[ ! -d ${MIGRATIONS_DIR} ]]; then
echo "[migrations] no migrations found" echo "[migrations] no migrations found"
exit exit
fi fi
for MIGRATION in $(ls -1 ${MIGRATIONS_DIR}/* | sort -n); do for MIGRATION in $(find ${MIGRATIONS_DIR}/* | sort -n); do
NAME="$(basename "${MIGRATION}")" NAME="$(basename "${MIGRATION}")"
if [ -f $MIGRATIONS_HISTORY ] && grep -Fxq "$NAME" $MIGRATIONS_HISTORY; then if [[ -f ${MIGRATIONS_HISTORY} ]] && grep -Fxq "${NAME}" ${MIGRATIONS_HISTORY}; then
echo "[migrations] ${NAME}: skipped" echo "[migrations] ${NAME}: skipped"
continue continue
fi fi
echo "[migrations] ${NAME}: executing..." echo "[migrations] ${NAME}: executing..."
chmod +x $MIGRATION chmod +x "${MIGRATION}"
EXIT_CODE=$(/bin/bash ${MIGRATION}; echo $?) EXIT_CODE=$(/bin/bash "${MIGRATION}"; echo $?)
if [ $EXIT_CODE -ne 0 ]; then if [[ ${EXIT_CODE} -ne 0 ]]; then
echo "[migrations] ${NAME}: failed with exit code $EXIT_CODE, contact support" echo "[migrations] ${NAME}: failed with exit code ${EXIT_CODE}, contact support"
exit $EXIT_CODE exit "${EXIT_CODE}"
fi fi
echo $NAME >> $MIGRATIONS_HISTORY echo "${NAME}" >> ${MIGRATIONS_HISTORY}
echo "[migrations] ${NAME}: succeeded" echo "[migrations] ${NAME}: succeeded"
done done