Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel migration uknown database enum requested

Live application have order table.

    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');
    });

Now I need to update status field in that table, but I want to save old data in database. So I created one more migration which will update status field in order table.

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

But when i run php artisan migrate I got error saying Unknow database type enum requested, Doctrine\DBal\Platforms\MySqlPlatform may not support it.

like image 612
Gardelin Avatar asked Jun 05 '26 14:06

Gardelin


1 Answers

I suggest you to use facade of query builder to achieve the same,

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

By raw migration it is not possible,

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.

like image 74
Rahul Avatar answered Jun 07 '26 12:06

Rahul