How to Change Table Name using Laravel Migration?

Admin   Laravel   27  2020-07-29 20:41:21

Hi All,

Today, i will let you know example of laravel migration rename table name. it's simple example of change table name in laravel migration. i explained simply about change table name using migration laravel. i explained simply step by step rename table in laravel migration. You just need to some step to done change table name in laravel migration.

We can easily rename table name using Schema rename method. so let's see bellow syntax and example as bellow:

Syntax:

Schema::rename('old_table_name', 'new_table_name');

Example:

<?php

use Illuminate\Support\Facades\Schema;

use Illuminate\Database\Schema\Blueprint;

use Illuminate\Database\Migrations\Migration;

class ChangePostsTableName extends Migration

{

/**

* Run the migrations.

*

* @return void

*/

public function up()

{

Schema::rename('posts', 'articales');

}

/**

* Reverse the migrations.

*

* @return void

*/

public function down()

{

}

}

I hope it can help you...