Laravel Drop Table Using Migration


Laravel Drop Table Using Migration – We can use migration to drop the database table using the artisan command. Here in this tutorial we are going to explain how you can drop database table in Laravel.


Laravel Drop Table Using Migration | with full Example.

Let us understand how to use Laravel Drop Table Using Migration.

Full example of delete table using migration.

Now here i am going to explain how to delete table step by step.

As we discussed in previous post to create a table using migration now i am going to show how to delete table using artisan command.

Migration File:-

Migration file:-

Let’s look at a simple example.

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

class CreateUsersTable extends Migration
{
   
    public function up()
    {
        Schema::create('sonu1', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->string('email');
            $table->string('password');
            $table->rememberToken();
            $table->timestamps();
        });
    }
	
    public function down()
    {
        Schema::dropIfExists('sonu1');
    }
}

Then run some command in command prompt:-

php artisan migrate:rollback

Then we can see table will be deleted from database.

Before deleted

Laravel Drop Table Using Migration

After deleted

Laravel Drop Table Using Migration

Advertisements

Add Comment

📖 Read More