Laravel migrations change a column type from varchar to longText Laravel migrations change a column type from varchar to longText laravel laravel

Laravel migrations change a column type from varchar to longText


You can create a new migration and change just one column type:

public function up(){    Schema::table('sometable', function (Blueprint $table) {        $table->text('text')->change();    });}

You need to install doctrine/dbal to make this work

composer require doctrine/dbal

Works with Laravel 5.0+. It does not work with Laravel 4.2.


According to Laravel Doc

You can do it like

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

be sure to add the doctrine/dbal dependency to your composer.json file


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();        });    }}