Search code examples
phpsymfonydoctrine-orm

Unknown database type enum requested, Doctrine\DBAL\Platforms\MySQL57Platform may not support it. Symfony


I created a fresh symfony4 project. Made user Entity using php bin/console make:user, then tried to migrate using php bin/console make:migration. But then the error pops up

In AbstractPlatform.php line 434:

Unknown database type enum requested, Doctrine\DBAL\Platforms\MySQL57Platform may not support it.

The strange thing is the User entity doesn't have any enum type rather it has a json column of roles, I suppose this is the reason.

 /**
 * @ORM\Column(type="json")
 */
 private $roles = [];

I have seen some answers for the similar question for laravel, But don't know how to fix it in symfony4.


Solution

  • Couldn't reproduce your issue. But anyway you can set up enum type in doctrine.yaml like

    doctrine:
        dbal:
           .....
            mapping_types:
                enum: string
    

    Here is the corresponding part in the Symfony documentation.