Laravel migration change column type

2024-04-27 05:51:40 Khushi Laravel

How to change column type in Laravel Migration

In this trick we will see how to change column data type for example we are going to change a field from varchar to longText. To do this create a new migration file and add below code and run that migration.

Example:

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

Command to run single migration

php artisan migrate --path=/database/migrations/your_migration.php

This post is submitted by one of our members. You may submit a new post here.

Related Tricks