First Commit
This commit is contained in:
Executable
+44
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||
use Symfony\Component\Console\Helper\Table;
|
||||
|
||||
class DbShowCommand extends Command
|
||||
{
|
||||
protected static $defaultName = 'db:show';
|
||||
protected static $defaultDescription = 'Exibe informações sobre o banco de dados';
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$connection = Capsule::connection();
|
||||
$dbName = $connection->getDatabaseName();
|
||||
|
||||
$output->writeln("<info>Banco de Dados: {$dbName}</info>");
|
||||
$output->writeln("Driver: " . $connection->getDriverName());
|
||||
|
||||
$tables = $connection->select('SHOW TABLE STATUS');
|
||||
|
||||
$table = new Table($output);
|
||||
$table->setHeaders(['Tabela', 'Engine', 'Rows', 'Size (MB)', 'Collation']);
|
||||
|
||||
foreach ($tables as $t) {
|
||||
$size = round(($t->Data_length + $t->Index_length) / 1024 / 1024, 2);
|
||||
$table->addRow([
|
||||
$t->Name,
|
||||
$t->Engine,
|
||||
$t->Rows,
|
||||
$size,
|
||||
$t->Collation
|
||||
]);
|
||||
}
|
||||
|
||||
$table->render();
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user