Skip to content

"Unknown column type "mediumInteger" requested" error after downgrading doctrine/dbal to 2.* #36509

@sentisso

Description

@sentisso
  • Laravel Version: 8.0
  • PHP Version: 7.4.3
  • Database Driver & Version: mysql Ver 15.1 Distrib 10.4.11-MariaDB

Description:

I was having an issue with migrations when trying to change column types. It was the Class 'Doctrine\DBAL\Driver\PDOMySql\Driver' not found error after trying to migrate. I managed to solve this specific error by downgrading doctrine/dbal to 2.*.

But now I get this error when trying to migrate to change column types:

C:\path_to_my_project>php artisan migrate

   Doctrine\DBAL\Exception 

  Unknown column type "mediuminteger" requested. Any Doctrine type that you use has to be registered with \Doctrine\DBAL\Types\Type
::addType(). You can get a list of all the known types with \Doctrine\DBAL\Types\Type::getTypesMap(). If this error occurs during d
atabase introspection then you might have forgotten to register all database types for a Doctrine Type. Use AbstractPlatform#regist
erDoctrineTypeMapping() or have your custom types implement Type#getMappedDatabaseTypes(). If the type name is empty you might have
 a problem with the cache or forgot some mapping information.

  at C:\path_to_my_project\vendor\doctrine\dbal\lib\Doctrine\DBAL\DBALException.php:282
    278▕      * @return Exception
    279▕      */
    280▕     public static function unknownColumnType($name)
    281▕     {
  ➜ 282▕         return new Exception('Unknown column type "' . $name . '" requested. Any Doctrine type that you use has ' .
    283▕             'to be registered with \Doctrine\DBAL\Types\Type::addType(). You can get a list of all the ' .
    284▕             'known types with \Doctrine\DBAL\Types\Type::getTypesMap(). If this error occurs during database ' .
    285▕             'introspection then you might have forgotten to register all database types for a Doctrine Type. Use ' .
    286▕             'AbstractPlatform#registerDoctrineTypeMapping() or have your custom types implement ' .

  1   C:\path_to_my_project\vendor\doctrine\dbal\lib\Doctrine\DBAL\Types\TypeRegistry.php:39
      Doctrine\DBAL\DBALException::unknownColumnType("mediuminteger")

  2   C:\path_to_my_project\vendor\doctrine\dbal\lib\Doctrine\DBAL\Types\Type.php:233
      Doctrine\DBAL\Types\TypeRegistry::get("mediuminteger")

This is the migration code:

public function up()
{
    Schema::table('opening_hours', function (Blueprint $table) {
        $table->mediumInteger("open_time")->unsigned()->nullable()->change();
        $table->mediumInteger("close_time")->unsigned()->nullable()->change();
    });
}

Steps To Reproduce:

theoretically:

  1. Create a migration file for modifying an existing table
  2. Try to change a columns type value to mediumInteger
  3. php artisan migrate

There might be the Driver not found error, so follow to this issue and downgrade doctrine/dbal to 2.*

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions