From ca5710b5aeb842dab6f72d5640947b870efe0db5 Mon Sep 17 00:00:00 2001 From: Christian Winther Date: Fri, 26 Jan 2024 20:45:38 +0000 Subject: [PATCH] fix 12-migrations.sh properly detecting new migrations and printing output --- .../root/docker/entrypoint.d/12-migrations.sh | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/docker/shared/root/docker/entrypoint.d/12-migrations.sh b/docker/shared/root/docker/entrypoint.d/12-migrations.sh index e7d52d7f..3b87daf1 100755 --- a/docker/shared/root/docker/entrypoint.d/12-migrations.sh +++ b/docker/shared/root/docker/entrypoint.d/12-migrations.sh @@ -12,17 +12,25 @@ entrypoint-set-script-name "$0" # Wait for the database to be ready await-database-ready -# Detect if we have new migrations -declare -i new_migrations=0 -(run-as-runtime-user php artisan migrate:status || :) | grep No && new_migrations=1 +# Run the migrate:status command and capture output +output=$(run-as-runtime-user php artisan migrate:status || :) -if is-true "${new_migrations}"; then - log-info "No outstanding migrations detected" +# By default we have no new migrations +declare -i new_migrations=0 + +# Detect if any new migrations are available by checking for "No" in the output +echo "$output" | grep No && new_migrations=1 + +if is-false "${new_migrations}"; then + log-info "No new migrations detected" exit 0 fi -log-warning "New migrations available!" +log-warning "New migrations available" + +# Print the output +echo "$output" if is-false "${DB_APPLY_NEW_MIGRATIONS_AUTOMATICALLY}"; then log-info "Automatic applying of new database migrations is disabled"