onlinecode

How to Change Table Name using Laravel Migration?

How to Change Table Name using Laravel Migration?

In this post we will give you information about How to Change Table Name using Laravel Migration?. Hear we will give you detail about How to Change Table Name using Laravel Migration?And how to use it also give you demo for it if it is necessary.

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:

Also see:How to Remove Column from Table in Laravel Migration?

<?php

use IlluminateSupportFacadesSchema;

use IlluminateDatabaseSchemaBlueprint;

use IlluminateDatabaseMigrationsMigration;

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…

Hope this code and post will helped you for implement How to Change Table Name using Laravel Migration?. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Exit mobile version