---
description: >-
  https://www.itsolutionstuff.com/post/how-to-change-table-name-using-laravel-migrationexample.html
---

# How to Change Table Name using Laravel Migration? (ok)

C:\xampp\htdocs\reset\database\migrations\2022\_05\_20\_180539\_create\_posts\_table.php

```
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreatePostsTable extends Migration {
  /**
   * Run the migrations.
   *
   * @return void
   */
  public function up() {
    Schema::create('posts', function (Blueprint $table) {
      $table->id();
      $table->string('title');
      $table->text('body');
      $table->boolean('is_publish')->default(0);
      $table->timestamps();
    });
  }
  /**
   * Reverse the migrations.
   *
   * @return void
   */
  public function down() {
    Schema::dropIfExists('posts');
  }
}
```

C:\xampp\htdocs\reset\database\migrations\2022\_05\_20\_180718\_change\_posts\_table\_column.php

```
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class ChangePostsTableColumn extends Migration {
  /**
   * Run the migrations.
   *
   * @return void
   */
  public function up() {
    Schema::rename('posts', 'articales');
  }
  /**
   * Reverse the migrations.
   *
   * @return void
   */
  public function down() {
    //
  }
}
```

![](https://1592565776-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LVfVRgKBlsVnWvhnDaa%2Fuploads%2Fkm0LD8UwRTOX1bSs4liD%2FScreenshot_8.png?alt=media\&token=0d8319d2-c4c8-4b48-8bfb-37fd08343479)

## How to Change Table Name using Laravel Migration?

By Hardik Savani April 1, 2020 Category : Laravel![](https://a.vdo.ai/core/assets/img/cross.svg)PlayUnmuteLoaded: 1.01%Fullscreen[![VDO.AI](https://a.vdo.ai/core/assets/img/logo.svg)](https://vdo.ai/?utm_medium=video\&utm_term=itsolutionstuff.com\&utm_source=vdoai_logo)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 see example of change table name using migration in laravel 6, laravel 7, laravel 8 and laravel 9.

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:**

Read Also: [How to Remove Column from Table in Laravel Migration?](https://www.itsolutionstuff.com/post/how-to-remove-column-from-table-in-laravel-migrationexample.html)

```
<?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...
