@@ -39,32 +39,38 @@ public function handle(ConnectionResolverInterface $connections)
39
39
{
40
40
$ connection = $ connections ->connection ($ this ->input ->getOption ('database ' ));
41
41
$ schema = $ connection ->getSchemaBuilder ();
42
- $ tables = $ schema ->getTables ();
42
+ $ tables = collect ($ schema ->getTables ())
43
+ ->keyBy (fn ($ table ) => $ table ['schema ' ] ? $ table ['schema ' ].'. ' .$ table ['name ' ] : $ table ['name ' ])
44
+ ->all ();
43
45
44
46
$ tableName = $ this ->argument ('table ' ) ?: select (
45
47
'Which table would you like to inspect? ' ,
46
- array_column ($ tables, ' name ' )
48
+ array_keys ($ tables )
47
49
);
48
50
49
- $ table = Arr::first ($ tables , fn ($ table ) => $ table ['name ' ] === $ tableName );
51
+ $ table = $ tables [ $ tableName ] ?? Arr::first ($ tables , fn ($ table ) => $ table ['name ' ] === $ tableName );
50
52
51
53
if (! $ table ) {
52
54
$ this ->components ->warn ("Table [ {$ tableName }] doesn't exist. " );
53
55
54
56
return 1 ;
55
57
}
56
58
57
- $ tableName = $ this ->withoutTablePrefix ($ connection , $ table ['name ' ]);
59
+ $ tableName = ( $ table [ ' schema ' ] ? $ table [ ' schema ' ]. ' . ' : '' ). $ this ->withoutTablePrefix ($ connection , $ table ['name ' ]);
58
60
59
61
$ columns = $ this ->columns ($ schema , $ tableName );
60
62
$ indexes = $ this ->indexes ($ schema , $ tableName );
61
63
$ foreignKeys = $ this ->foreignKeys ($ schema , $ tableName );
62
64
63
65
$ data = [
64
66
'table ' => [
67
+ 'schema ' => $ table ['schema ' ],
65
68
'name ' => $ table ['name ' ],
66
69
'columns ' => count ($ columns ),
67
70
'size ' => $ table ['size ' ],
71
+ 'comment ' => $ table ['comment ' ],
72
+ 'collation ' => $ table ['collation ' ],
73
+ 'engine ' => $ table ['engine ' ],
68
74
],
69
75
'columns ' => $ columns ,
70
76
'indexes ' => $ indexes ,
@@ -103,6 +109,7 @@ protected function getAttributesForColumn($column)
103
109
{
104
110
return collect ([
105
111
$ column ['type_name ' ],
112
+ $ column ['generation ' ] ? $ column ['generation ' ]['type ' ] : null ,
106
113
$ column ['auto_increment ' ] ? 'autoincrement ' : null ,
107
114
$ column ['nullable ' ] ? 'nullable ' : null ,
108
115
$ column ['collation ' ],
@@ -197,11 +204,19 @@ protected function displayForCli(array $data)
197
204
198
205
$ this ->newLine ();
199
206
200
- $ this ->components ->twoColumnDetail ('<fg=green;options=bold> ' .$ table ['name ' ].'</> ' );
207
+ $ this ->components ->twoColumnDetail ('<fg=green;options=bold> ' .( $ table ['schema ' ] ? $ table [ ' schema ' ]. ' . ' . $ table [ ' name ' ] : $ table [ ' name ' ]) .'</> ' , $ table [ ' comment ' ] ? ' <fg=gray> ' . $ table [ ' comment ' ]. ' </> ' : null );
201
208
$ this ->components ->twoColumnDetail ('Columns ' , $ table ['columns ' ]);
202
209
203
- if ($ size = $ table ['size ' ]) {
204
- $ this ->components ->twoColumnDetail ('Size ' , Number::fileSize ($ size , 2 ));
210
+ if (! is_null ($ table ['size ' ])) {
211
+ $ this ->components ->twoColumnDetail ('Size ' , Number::fileSize ($ table ['size ' ], 2 ));
212
+ }
213
+
214
+ if ($ table ['engine ' ]) {
215
+ $ this ->components ->twoColumnDetail ('Engine ' , $ table ['engine ' ]);
216
+ }
217
+
218
+ if ($ table ['collation ' ]) {
219
+ $ this ->components ->twoColumnDetail ('Collation ' , $ table ['collation ' ]);
205
220
}
206
221
207
222
$ this ->newLine ();
0 commit comments