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.
Couldn't reproduce your issue. But anyway you can set up enum type in doctrine.yaml like
doctrine:
dbal:
.....
mapping_types:
enum: string
To fix this, you can register that type mapping on your migration:
DB::connection()->getDoctrineSchemaManager()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
Also, you could register it on app\Providers\AppServiceProvider.php
.
public function boot() {
// ...
DB::connection()
->getDoctrineSchemaManager()
->getDatabasePlatform()
->registerDoctrineTypeMapping('enum', 'string');
// ....
}
Source: https://github.com/doctrine/dbal/issues/3161#issuecomment-542814085
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With