Laravel 迁移未知数据库枚举请求



实时应用程序有订单表。

Schema::create('order', function($table){
$table->increments('id');
$table->integer('user_id')->unsigned();
$table->dateTime('date')->nullable();
$table->enum('status', array('CREATED','FINISHED'))->default('CREATED');
});

现在我需要更新该表中的状态字段,但我想将旧数据保存在数据库中。所以我又创建了一个迁移,它将更新订单表中的状态字段。

Schema::table('order', function($table){
$table->enum('status', array('CREATED','FINISHED','CLOSED'))->default('CREATED')->change();
});

但是当我运行php artisan migrate时,我错误地说Unknow database type enum requested, DoctrineDBalPlatformsMySqlPlatform may not support it.

我建议您使用查询生成器的外观来实现相同的目的,

DB::statement("ALTER TABLE order CHANGE COLUMN status status  
ENUM('CREATED', 'FINISHED', 'CLOSED') NOT NULL DEFAULT 'CREATED'");

通过原始迁移是不可能的,

注意:-只能"更改"以下列类型:大整数、二进制、布尔值、日期、日期时间、日期时间、十进制、 整数, json, 长文本, 中文本, 小整数, 字符串, 文本, 时间, unsignedBigInteger、unsignedInteger 和 unsignedSmallInteger。

最新更新