Laravel Class 'Doctrine\DBAL\Driver\PDOMySql\Driver' not found

Laravel: 5.5.*

在迁移中有重命名操作的时候,运行 php artisan migrate 会提示 Class 'Doctrine\DBAL\Driver\PDOMySql\Driver' not found的错误信息,

可通过composer 安装 doctrine/dbal 类库,然后运行 迁移就可以了


修改 表字段的 enum值时,使用DB::statement() 方法进行修改字段的ENUM值

migration 文件中有以下代码:

Schema::table('users', function (Blueprint $table) {
    if (Schema::hasColumn('users', 'social')) {
        $table->enum('social',[
            'weibo',
            'zhihu',
            'qq'
        ])->default('weibo')->index()->change();
    }
});

运行 php artisan migrate 显示以下错误信息:

In AbstractPlatform.php line 434:   
  Unknown database type enum requested, Doctrine\DBAL\Platforms\MySQL57Platform may not support it.

migration 改为:

Schema::table('users', function (Blueprint $table) {
	if (Schema::hasColumn('users', 'social')) {
      DB::statement("ALTER TABLE users MODIFY COLUMN social ENUM('weibo','zhihu','qq')");
    }
});

然后运行php artisan migrate 就可以修改到 用户表中的social的 enum 值

Reference
  1. 关于laravel renameColumn 更改字段报错
  2. [Bug] Schema builder - renameColumn fails on table with enum columns
posted @ 2019-08-11 22:11  五毛钱的饼  阅读(1371)  评论(1编辑  收藏  举报