Răsfoiți Sursa

fix 12-migrations.sh properly detecting new migrations and printing output

Christian Winther 1 an în urmă
părinte
comite
ca5710b5ae
1 a modificat fișierele cu 13 adăugiri și 5 ștergeri
  1. 13 5
      docker/shared/root/docker/entrypoint.d/12-migrations.sh

+ 13 - 5
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
+# Run the migrate:status command and capture output
+output=$(run-as-runtime-user php artisan migrate:status || :)
+
+# By default we have no new migrations
 declare -i new_migrations=0
-(run-as-runtime-user php artisan migrate:status || :) | grep No && new_migrations=1
 
-if is-true "${new_migrations}"; then
-    log-info "No outstanding migrations detected"
+# 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"