3

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.

Gardelin
  • 950
  • 11
  • 30
  • 3
    From the [documentation](https://laravel.com/docs/5.8/migrations#modifying-columns): "_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._" and also "_Renaming any column in a table that also has a column of type enum is not currently supported._" – brombeer Sep 12 '19 at 09:30
  • Possible duplicate of [Laravel 5.1 Unknown database type enum requested](https://stackoverflow.com/questions/33140860/laravel-5-1-unknown-database-type-enum-requested) –  Sep 12 '19 at 09:30

1 Answers1

1

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.

Rahul
  • 18,271
  • 7
  • 41
  • 60