diff --git a/src/Illuminate/Database/Console/DatabaseInspectionCommand.php b/src/Illuminate/Database/Console/DatabaseInspectionCommand.php index 1125d0384103..62102c655438 100644 --- a/src/Illuminate/Database/Console/DatabaseInspectionCommand.php +++ b/src/Illuminate/Database/Console/DatabaseInspectionCommand.php @@ -16,6 +16,25 @@ abstract class DatabaseInspectionCommand extends Command { + /** + * A map of database column types. + * + * @var array + */ + protected $typeMappings = [ + 'bit' => 'string', + 'enum' => 'string', + 'geometry' => 'string', + 'geomcollection' => 'string', + 'linestring' => 'string', + 'multilinestring' => 'string', + 'multipoint' => 'string', + 'multipolygon' => 'string', + 'point' => 'string', + 'polygon' => 'string', + 'sysname' => 'string', + ]; + /** * The Composer instance. * @@ -193,4 +212,17 @@ protected function installDependencies() } } } + + /** + * Register custom Doctrine type mappings. + * + * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform + * @return void + */ + protected function registerTypeMapping(AbstractPlatform $platform) + { + foreach ($this->typeMappings as $type => $value) { + $platform->registerDoctrineTypeMapping($type, $value); + } + } } diff --git a/src/Illuminate/Database/Console/ShowCommand.php b/src/Illuminate/Database/Console/ShowCommand.php index 125de1cac558..6a4c300db44c 100644 --- a/src/Illuminate/Database/Console/ShowCommand.php +++ b/src/Illuminate/Database/Console/ShowCommand.php @@ -44,6 +44,8 @@ public function handle(ConnectionResolverInterface $connections) $schema = $connection->getDoctrineSchemaManager(); + $this->registerTypeMapping($schema->getDatabasePlatform()); + $data = [ 'platform' => [ 'config' => $this->getConfigFromDatabase($database), @@ -75,7 +77,7 @@ protected function tables(ConnectionInterface $connection, AbstractSchemaManager 'table' => $table->getName(), 'size' => $this->getTableSize($connection, $table->getName()), 'rows' => $this->option('counts') ? $connection->table($table->getName())->count() : null, - 'engine' => rescue(fn () => $table->getOption('engine')), + 'engine' => rescue(fn () => $table->getOption('engine'), null, false), 'comment' => $table->getComment(), ]); } diff --git a/src/Illuminate/Database/Console/TableCommand.php b/src/Illuminate/Database/Console/TableCommand.php index 7cc99162f721..f221e4727be7 100644 --- a/src/Illuminate/Database/Console/TableCommand.php +++ b/src/Illuminate/Database/Console/TableCommand.php @@ -42,6 +42,7 @@ public function handle(ConnectionResolverInterface $connections) $connection = $connections->connection($this->input->getOption('database')); $schema = $connection->getDoctrineSchemaManager(); + $this->registerTypeMapping($schema->getDatabasePlatform()); $table = $this->argument('table') ?: $this->components->choice( 'Which table would you like to inspect?', diff --git a/src/Illuminate/Foundation/Console/ShowModelCommand.php b/src/Illuminate/Foundation/Console/ShowModelCommand.php index 5a01b574cdc3..c5bca312f903 100644 --- a/src/Illuminate/Foundation/Console/ShowModelCommand.php +++ b/src/Illuminate/Foundation/Console/ShowModelCommand.php @@ -113,6 +113,7 @@ public function handle() protected function getAttributes($model) { $schema = $model->getConnection()->getDoctrineSchemaManager(); + $this->registerTypeMapping($schema->getDatabasePlatform()); $table = $model->getConnection()->getTablePrefix().$model->getTable(); $columns = $schema->listTableColumns($table); $indexes = $schema->listTableIndexes($table);