Laravel migrations change a column type from varchar to longText

前端 未结 5 2025
野性不改
野性不改 2021-02-02 06:49

I need to change with migration column type of $table->string(\'text\'); to a text type, I have tried to do that in few ways, but none of them worked. Is it poss

5条回答
  •  萌比男神i
    2021-02-02 07:40

    If you get following error using change()

    Unknown database type enum requested, Doctrine\DBAL\Platforms\MySQL80Platform may not support it.

    this means that exists some column (not necessarily changed one) in your table which has enum type. So instead using change() you can use following function:

    public function changeColumnType($table, $column, $newColumnType) {                
        DB::statement("ALTER TABLE $table CHANGE $column $column $newColumnType");
    } 
    

    And use it like that: $this->changeColumnType('sometable','text','TEXT');

提交回复
热议问题