Enable migration to be ignored, even if we have to migrate

This commit is contained in:
Deon George 2022-02-06 15:10:24 +11:00
parent 6d37d4ae78
commit 546ebcc610

28
init
View File

@ -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)" su www-data -s /bin/sh -c "(php artisan optimize && php artisan view:cache)"
fi fi
if [ -r .migrate ]; then if [ -z "${IGNORE_MIGRATION}" ]; then
echo "* Running migration..." if [ -r .migrate ]; then
# If DB_HOST not set, source the env file echo "* Running migration..."
[ -z "${DB_HOST}" -a -r .env ] && . .env # 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 if [ -n "${DB_HOST}" -a -n "${DB_PORT}" ]; then
while ! wait-for-it -h ${DB_HOST} -p ${DB_PORT} -t 5 -q; do while ! wait-for-it -h ${DB_HOST} -p ${DB_PORT} -t 5 -q; do
echo "? Waiting for database at ${DB_HOST}:${DB_PORT}" echo "? Waiting for database at ${DB_HOST}:${DB_PORT}"
sleep 1; sleep 1;
done done
echo "- DB is active on ${DB_HOST}:${DB_PORT}" echo "- DB is active on ${DB_HOST}:${DB_PORT}"
fi
su www-data -s /bin/sh -c "php artisan migrate" && rm -f .migrate
fi fi
else
su www-data -s /bin/sh -c "php artisan migrate" && rm -f .migrate [ -r .migrate ] && echo "! NOTE: Migration ignored due to IGNORE_MIGRATION"
fi fi
# If passport is installed # If passport is installed