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)"
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