Merge pull request #78 from quietsy/focal

Add migrations support
pull/81/head focal-da65f816-ls59
Eric Nemchik 2021-12-05 13:36:04 -06:00 zatwierdzone przez GitHub
commit 3d71f4a517
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 30 dodań i 0 usunięć

Wyświetl plik

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