浏览代码

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

Christian Winther 1 年之前
父节点
当前提交
ca5710b5ae
共有 1 个文件被更改,包括 13 次插入5 次删除
  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
 # Wait for the database to be ready
 await-database-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
 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
     exit 0
 fi
 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
 if is-false "${DB_APPLY_NEW_MIGRATIONS_AUTOMATICALLY}"; then
     log-info "Automatic applying of new database migrations is disabled"
     log-info "Automatic applying of new database migrations is disabled"