Laravel db migration - renameColumn error - Unknown database type enum requested

前端 未结 8 865
暗喜
暗喜 2020-12-10 11:53

I am using Laravel 4.2. I have the following library loaded in my composer.json

\"doctrine/dbal\": \"2.4.*\",

I c

8条回答
  •  我在风中等你
    2020-12-10 12:17

    Currently, there is no legal solution for this problem except avoiding enums, but there is a workaround:

    Create migration with the following:

    public function up()
    {
        DB::statement("ALTER TABLE `table` CHANGE `example_enum_column` `example_enum_column` ENUM('enum1', 'enum2', 'enum3+');");
    }
    

    And that will do the trick with the ENUM update you are looking for. Additionally, you can create handle down functions to revert field status as it used to be:

     public function down() 
     {
         DB::statement("ALTER TABLE `table` CHANGE `example_enum_column` `example_enum_column` ENUM('enum1', 'enum2');"); 
     }
    

提交回复
热议问题