getDatabaseName(); $output->writeln("Otimizando banco de dados: {$dbName}"); $tables = $connection->select('SHOW TABLES'); $key = "Tables_in_{$dbName}"; foreach ($tables as $table) { $tableName = $table->$key; $output->write("Otimizando tabela: {$tableName}... "); try { $connection->statement("OPTIMIZE TABLE {$tableName}"); $output->writeln('OK'); } catch (\Exception $e) { $output->writeln('Erro ao otimizar'); } } $output->writeln('Otimização concluída!'); return Command::SUCCESS; } }