laravel 执行迁移时 Unknown database type json requested, Doctrine\DBAL\Platforms\MySQL57Platform may n...

laravel 执行迁移时 Unknown database type json requested, Doctrine\DBAL\Platforms\MySQL57Platform may not support it 报错,原因是我在创建表的时候字段用的是json类型,后来发现json不能为空,我把字段改为varchar,然后再发现varchar长度不够了,再改长度的话就报这个错,在类里加上这个魔术方法就行了

public function __construct()
{
    DB::getDoctrineSchemaManager()->getDatabasePlatform()->registerDoctrineTypeMapping('json', 'string');
}

推荐阅读更多精彩内容