@@ -39,10 +39,8 @@ class TableCommand extends DatabaseInspectionCommand
39
39
public function handle (ConnectionResolverInterface $ connections )
40
40
{
41
41
$ connection = $ connections ->connection ($ this ->input ->getOption ('database ' ));
42
- $ schema = $ connection ->getSchemaBuilder ();
43
- $ tables = (new Collection ($ schema ->getTables ()))
44
- ->keyBy (fn ($ table ) => $ table ['schema ' ] ? $ table ['schema ' ].'. ' .$ table ['name ' ] : $ table ['name ' ])
45
- ->all ();
42
+ $ tables = (new Collection ($ connection ->getSchemaBuilder ()->getTables ()))
43
+ ->keyBy ('schema_qualified_name ' )->all ();
46
44
47
45
$ tableName = $ this ->argument ('table ' ) ?: select (
48
46
'Which table would you like to inspect? ' ,
@@ -57,16 +55,22 @@ public function handle(ConnectionResolverInterface $connections)
57
55
return 1 ;
58
56
}
59
57
60
- $ tableName = ($ table ['schema ' ] ? $ table ['schema ' ].'. ' : '' ).$ this ->withoutTablePrefix ($ connection , $ table ['name ' ]);
58
+ [$ columns , $ indexes , $ foreignKeys ] = $ connection ->withoutTablePrefix (function ($ connection ) use ($ table ) {
59
+ $ schema = $ connection ->getSchemaBuilder ();
60
+ $ tableName = $ table ['schema_qualified_name ' ];
61
61
62
- $ columns = $ this ->columns ($ schema , $ tableName );
63
- $ indexes = $ this ->indexes ($ schema , $ tableName );
64
- $ foreignKeys = $ this ->foreignKeys ($ schema , $ tableName );
62
+ return [
63
+ $ this ->columns ($ schema , $ tableName ),
64
+ $ this ->indexes ($ schema , $ tableName ),
65
+ $ this ->foreignKeys ($ schema , $ tableName ),
66
+ ];
67
+ });
65
68
66
69
$ data = [
67
70
'table ' => [
68
71
'schema ' => $ table ['schema ' ],
69
72
'name ' => $ table ['name ' ],
73
+ 'schema_qualified_name ' => $ table ['schema_qualified_name ' ],
70
74
'columns ' => count ($ columns ),
71
75
'size ' => $ table ['size ' ],
72
76
'comment ' => $ table ['comment ' ],
@@ -205,7 +209,7 @@ protected function displayForCli(array $data)
205
209
206
210
$ this ->newLine ();
207
211
208
- $ this ->components ->twoColumnDetail ('<fg=green;options=bold> ' .( $ table ['schema ' ] ? $ table [ ' schema ' ]. ' . ' . $ table [ ' name ' ] : $ table [ ' name ' ]) .'</> ' , $ table ['comment ' ] ? '<fg=gray> ' .$ table ['comment ' ].'</> ' : null );
212
+ $ this ->components ->twoColumnDetail ('<fg=green;options=bold> ' .$ table ['schema_qualified_name ' ] .'</> ' , $ table ['comment ' ] ? '<fg=gray> ' .$ table ['comment ' ].'</> ' : null );
209
213
$ this ->components ->twoColumnDetail ('Columns ' , $ table ['columns ' ]);
210
214
211
215
if (! is_null ($ table ['size ' ])) {
0 commit comments