info('No materialized views configured.'); return self::SUCCESS; } $concurrently = $this->option('concurrently') ? ' CONCURRENTLY' : ''; foreach ($views as $view) { $name = trim((string) $view); if ($name === '') { continue; } $sql = 'REFRESH MATERIALIZED VIEW'.$concurrently.' '.DB::getPdo()->quote($name); // PDO::quote wraps with single quotes; for identifiers we need double quotes or no quotes. // Use a safe fallback: wrap with " if not already quoted $safe = 'REFRESH MATERIALIZED VIEW'.$concurrently.' "'.str_replace('"', '""', $name).'"'; try { DB::statement($safe); $this->info("Refreshed: {$name}"); } catch (\Throwable $e) { $this->error("Failed to refresh {$name}: ".$e->getMessage()); } } return self::SUCCESS; } }