Laravel migrations change a column type from varchar to longText

前端 未结 5 1954
野性不改
野性不改 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条回答
  •  难免孤独
    2021-02-02 07:51

    Following worked for me.

    Definitely you need to install doctrine/dbal to make this work, using following command in terminal.

    composer require doctrine/dbal
    

    Then create migration as mentioned here- https://laravel.com/docs/master/migrations#generating-migrations

    open your migration file and write down below.

    Schema::table('yourTable', function (Blueprint $table) {
        $table->string('column_name','4294967295')->change();
    });
    

    As, longText have maximum of 4,294,967,295 character limit, Laravel will automatically change column_name to longText data type.

提交回复
热议问题