77use DragonCode \MigrateDB \Facades \BuilderManager ;
88use DragonCode \Support \Facades \Helpers \Arr ;
99use Illuminate \Console \Command ;
10+ use Illuminate \Database \Connection ;
1011use Illuminate \Database \Query \Builder as QueryBuilder ;
1112use Illuminate \Support \Collection ;
1213use Illuminate \Support \Facades \DB ;
1617class Migrateextends Command
1718{
1819protected $ signature ='db:migrate '
19- .' {--schema-from= : Source connection name} '
20- .' {--schema-to= : Target connection name} '
21- .' {--exclude=* : Comma separated table names to exclude} '
22- .' {--tables=* : Comma separated table names to migrate only} ' ;
20+ .' {--schema-from= : Source connection name} '
21+ .' {--schema-to= : Target connection name} '
22+ .' {--exclude=* : Comma separated table names to exclude} '
23+ .' {--tables=* : Comma separated table names to migrate only} ' ;
2324
2425protected $ description ='Data transfer from one database to another ' ;
2526
@@ -252,7 +253,10 @@ protected function getMigrationOption(): string
252253
253254protected function confirmTableListOption ():bool
254255 {
255- return $ this ->confirm ('Please confirm table list should be retrieved from target connection? (incase if source connection does not support it) ' ,false );
256+ return $ this ->confirm (
257+ 'Please confirm table list should be retrieved from target connection? (incase if source connection does not support it) ' ,
258+ false
259+ );
256260 }
257261
258262protected function confirmTruncateTableOption ():bool
@@ -311,7 +315,7 @@ protected function resolveOptions(): void
311315
312316protected function builder (string $ connection ,string $ table ):QueryBuilder
313317 {
314- return DB :: connection ($ connection )->table ($ table );
318+ return $ this -> connection ($ connection )->table ($ table );
315319 }
316320
317321protected function doesntHasTable (string $ connection ,string $ table ):bool
@@ -321,6 +325,15 @@ protected function doesntHasTable(string $connection, string $table): bool
321325
322326protected function getPrimaryKeyType (string $ connection ,string $ table ,string $ column ):string
323327 {
324- return DB ::connection ($ connection )->getDoctrineColumn ($ table ,$ column )->getType ()->getName ();
328+ if (method_exists ($ this ->connection ($ connection ),'getDoctrineColumn ' )) {
329+ return $ this ->connection ($ connection )->getDoctrineColumn ($ table ,$ column )->getType ()->getName ();
330+ }
331+
332+ return $ this ->connection ($ connection )->getSchemaBuilder ()->getColumnType ($ table ,$ column );
333+ }
334+
335+ protected function connection (string $ name ):Connection
336+ {
337+ return DB ::connection ($ name );
325338 }
326339}