Changing column after migration

We create a lot of migrations if we are developing a large project so mistakes are possible. How will you change a table if the migration is already created? Let's see.

Laravel 5 supports changing columns

Schema::table('users', function($table)

{


    $table->string('name', 50)->nullable()->change();

});

For Laravel 4, you should install DBAL package using composer.

composer require doctrine/dbal

 Then you need to write raw sql commands. 

$app =app();

$laravelVer= explode('.',$app::VERSION); 

    switch ($laravelVer[0]) {       

    case('5') :                           

        Schema::table('pro_categories_langs', function(Blueprint $t) {              

        $t->string('name', 100)->nullable()->default(null)->change();          

        });                         

     break;                               

    default :                           

        DB::statement('ALTER TABLE `pro_categories_langs` MODIFY `name`VARCHAR(100) NULL;');

    }