Migration 的修改字段报错

Schema::create('test',function($table){

   $table->increments('id');   

   $table->char('name',8);

   $table->string('email','32'); 

   $table->enum('sex',['1','0']);

   $table->char('password',32); 

   $table->timestamps();  

   $table->softDeletes();

});
<br></br>

执行添加后,没任何问题。但我在测试修改字段的时候发现有报错。

Schema::table('test', function ($table) { 
   $table->string('name', 50)->change();
});<br></br>

执行后报错

[Doctrine\\DBAL\\DBALException] Unknown database type enum requested, Doctrine\\DBAL\\Platforms\\MySqlPlatform may not support it.

这就奇怪了,建表的时候没问题,特意看了sex的类型也是enum类型。

当我回滚,从建立表的时候,把sex字段去掉。之后添加和修改字段都没问题。

Tomoe


包含enum欄位的table也是一樣

tlijian1989

@Tomoe
我的操作不是从命名操作,而且操作的也不是enum类型的列。你的意思是只要包含enum类型,做列的修改都会报错吗

Tomoe

@tlijian1989 是啊,測試過蠻多次,只要該table包含了enum類型欄位,任何修改動作都會造成報錯,具體可以看該issue https://github.com/laravel/framework/issues/1186

snail

需要引入
doctrine/dbal
二楼已截图

tlijian1989

@snail
修改是需要doctrine/dbal,我的问题是因为有 enum类型的列。

snail

@tlijian1989 官方文档中备注:
Note: Modifying any column in a table that also has a column of type enum is not currently supported.