Skip to content

Commit 235eebf

Browse files
committed
get table size moved to schema
1 parent c3d0d7f commit 235eebf

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/Console/Commands/FindRiskyDatabaseColumns.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Illuminate\Support\Facades\DB;
1111
use Illuminate\Support\Facades\Schema;
1212
use Symfony\Component\Console\Attribute\AsCommand;
13+
use function Laravel\Prompts\table;
1314

1415
/**
1516
* Inspired by @see https://medium.com/beyn-technology/ill-never-forget-this-number-4294967295-0xffffffff-c9ad4b72f53a
@@ -101,7 +102,7 @@ public function handle(ConnectionResolverInterface $connections): int
101102
$outputTable = [];
102103

103104
foreach (Schema::getTables() as $table) {
104-
$riskyColumnsInfo = $this->processTable(Arr::get($table, 'name'), $connection, $thresholdAlarmPercentage);
105+
$riskyColumnsInfo = $this->processTable($table, $connection, $thresholdAlarmPercentage);
105106
if (is_array($riskyColumnsInfo)) {
106107
$outputTable = [...$outputTable, ...$riskyColumnsInfo];
107108
}
@@ -125,11 +126,12 @@ public function handle(ConnectionResolverInterface $connections): int
125126
/**
126127
* @return list<array<string, string>>|null
127128
*/
128-
private function processTable(string $tableName, Connection $connection, float $thresholdAlarmPercentage): ?array
129+
private function processTable(array $table, Connection $connection, float $thresholdAlarmPercentage): ?array
129130
{
131+
$tableName = Arr::get($table, 'name');
130132
$this->comment("Table {$connection->getDatabaseName()}.{$tableName}: checking...", 'v');
131133

132-
$tableSize = $this->getTableSize($connection, $tableName);
134+
$tableSize = Arr::get($table, 'size');
133135

134136
if ($tableSize === null) {
135137
$tableSize = -1; // not critical info, we can skip this issue

0 commit comments

Comments
 (0)