gpt4 book ai didi

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

转载 作者:搜寻专家 更新时间:2023-10-31 21:19:23 25 4
gpt4 key购买 nike

实时应用程序有订单表。

    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, Doctrine\DBal\Platforms\MySqlPlatform may not support it.

最佳答案

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

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

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

NOTE:- Only the following column types can be "changed": bigInteger, binary, boolean, date, dateTime, dateTimeTz, decimal, integer, json, longText, mediumText, smallInteger, string, text, time, unsignedBigInteger, unsignedInteger and unsignedSmallInteger.

关于php - Laravel 迁移未知数据库枚举请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57903636/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com