pull/127/head
Eric Nemchik 2022-10-28 16:21:44 -05:00
rodzic 9a4a2ba8dc
commit 787a600241
1 zmienionych plików z 20 dodań i 17 usunięć

Wyświetl plik

@ -1,4 +1,5 @@
#!/bin/bash #!/usr/bin/with-contenv bash
# shellcheck shell=bash
MIGRATIONS_DIR="/migrations" MIGRATIONS_DIR="/migrations"
MIGRATIONS_HISTORY="/config/.migrations" MIGRATIONS_HISTORY="/config/.migrations"
@ -18,12 +19,14 @@ for MIGRATION in $(find ${MIGRATIONS_DIR}/* | sort -n); do
fi fi
echo "[migrations] ${NAME}: executing..." echo "[migrations] ${NAME}: executing..."
chmod +x "${MIGRATION}" chmod +x "${MIGRATION}"
EXIT_CODE=$(/bin/bash "${MIGRATION}"; echo $?) # Execute migration script in a subshell to prevent it from modifying the current environment
("${MIGRATION}")
EXIT_CODE=$?
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