environment('production') && file_exists($this->flag_file)) { $session_info = json_decode(file_get_contents($this->flag_file), true); $started_at = $session_info['started_at'] ?? 'unknown'; // Create a detailed error message $message = "🚧 Database Migration in Progress\n\n"; $message .= "A database migration session is currently active.\n"; $message .= "Started at: {$started_at}\n\n"; $message .= "The application is temporarily unavailable to ensure data integrity.\n\n"; $message .= "To complete the migration session, run one of these commands:\n"; $message .= " • php artisan migrate:commit - Keep the changes\n"; $message .= " • php artisan migrate:rollback - Revert to snapshot\n\n"; $message .= "For status: php artisan migrate:status"; // Throw service unavailable exception throw new ServiceUnavailableHttpException( null, $message ); } return $next($request); } }