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

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

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

How to Change Table Name using Laravel Migration?

By Hardik Savani April 1, 2020 Category : LaravelPlayUnmuteLoaded: 1.01%FullscreenVDO.AIHi 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:

Example:

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

I hope it can help you...

Last updated

Was this helpful?