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

3

这个应用程序有一个订单表格。

    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时,出现错误提示请求未知的数据库类型enum,Doctrine\DBal\Platforms\MySqlPlatform可能不支持它。


3
根据文档,只有以下列类型可以进行“更改”:bigInteger、binary、boolean、date、dateTime、dateTimeTz、decimal、integer、json、longText、mediumText、smallInteger、string、text、time、unsignedBigInteger、unsignedInteger和unsignedSmallInteger。此外,“当前不支持重命名表中同时还有枚举类型列的任何列”。 - brombeer
可能是Laravel 5.1未知数据库类型枚举请求的重复问题。 - user10678889
1个回答

1

我建议您使用查询构建器的外观模式来实现相同的功能。

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

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

注意: 只有以下列类型可以“更改”:bigInteger、binary、boolean、date、dateTime、dateTimeTz、decimal、integer、json、longText、mediumText、smallInteger、string、text、time、unsignedBigInteger、unsignedInteger 和 unsignedSmallInteger。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接