Laravel migrations change a column type from varchar to longText

前端 未结 5 1947
野性不改
野性不改 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:48

    It's possible to do with a TABLE migration.

    As mentioned in other posts, be sure to run composer require doctrine/dbal from your project root.

    These are set up with:

    php artisan make:migration alter_table_[yourtablenamehere]_change_[somecolumnname] --table=[yourtablenamehere]
    

    from your project root.

    From the Documentation:

    https://laravel.com/docs/master/migrations#modifying-columns

    class AlterTableSomething extends Migration
    {
        /**
         * Run the migrations.
         *
         * @return void
         */
        public function up()
        {
            Schema::table('table', function (Blueprint $table) {
                $table->text('column_name')->change();
            });
        }
    }
    

提交回复
热议问题