From 546ebcc6105f1950122d1d53ec6f3ab58e6a46e5 Mon Sep 17 00:00:00 2001 From: Deon George Date: Sun, 6 Feb 2022 15:10:24 +1100 Subject: [PATCH] Enable migration to be ignored, even if we have to migrate --- init | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/init b/init index f62f390..cc7694b 100755 --- a/init +++ b/init @@ -104,20 +104,24 @@ if [ "${role}" = "app" -a -e artisan ]; then su www-data -s /bin/sh -c "(php artisan optimize && php artisan view:cache)" fi - if [ -r .migrate ]; then - echo "* Running migration..." - # If DB_HOST not set, source the env file - [ -z "${DB_HOST}" -a -r .env ] && . .env + if [ -z "${IGNORE_MIGRATION}" ]; then + if [ -r .migrate ]; then + echo "* Running migration..." + # If DB_HOST not set, source the env file + [ -z "${DB_HOST}" -a -r .env ] && . .env - if [ -n "${DB_HOST}" -a -n "${DB_PORT}" ]; then - while ! wait-for-it -h ${DB_HOST} -p ${DB_PORT} -t 5 -q; do - echo "? Waiting for database at ${DB_HOST}:${DB_PORT}" - sleep 1; - done - echo "- DB is active on ${DB_HOST}:${DB_PORT}" + if [ -n "${DB_HOST}" -a -n "${DB_PORT}" ]; then + while ! wait-for-it -h ${DB_HOST} -p ${DB_PORT} -t 5 -q; do + echo "? Waiting for database at ${DB_HOST}:${DB_PORT}" + sleep 1; + done + echo "- DB is active on ${DB_HOST}:${DB_PORT}" + fi + + su www-data -s /bin/sh -c "php artisan migrate" && rm -f .migrate fi - - su www-data -s /bin/sh -c "php artisan migrate" && rm -f .migrate + else + [ -r .migrate ] && echo "! NOTE: Migration ignored due to IGNORE_MIGRATION" fi # If passport is installed