How to Drop Soft Delete from Table using Laravel 10 Migration

Greetings, fellow developers! Today, we're tackling a common scenario that many Laravel artisans encounter: the need to bid farewell to Soft Delete in a database table. Whether you're streamlining your data structure or adjusting your application's requirements, the process of removing the deleted_at column can be pivotal.

In this step-by-step guide, we'll navigate through the world of Laravel 10 migrations to seamlessly drop Soft Delete from a table.

So, let's see how to drop soft delete from the table using laravel 10 migration, laravel 10 drop soft delete, laravel soft delete migration, and how to remove soft delete from the table using laravel 8/9/10.

Dropping Soft Delete from a table in Laravel 10 migration involves a few steps. Below is a step-by-step guide to help you through the process:

Step 1: Create a Migration

Begin by creating a migration using the Artisan command:

php artisan make:migration drop_soft_delete_from_table

 

Step 2: Open the Migration File

Navigate to the newly created migration file in the database/migrations directory and open it. Add the code for dropping the deleted_at column within the up method.

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class DropSoftDeleteFromTable extends Migration
{
    public function up()
    {
        Schema::table('users', function (Blueprint $table) {
            // Drop soft delete column
            $table->dropSoftDeletes();
        });
    }

    public function down()
    {
        Schema::table('users', function (Blueprint $table) {
            // If you want to add the soft delete column back in the rollback
            $table->softDeletes();
        });
    }
}

 

Step 3: Run the Migration

Execute the migration to apply the changes to your database:

php artisan migrate

And there you have it! You've successfully learned how to drop Soft Delete from a table using Laravel 10 migrations.

Happy coding! 🚀

 


 You might also like:

techsolutionstuff

Techsolutionstuff | The Complete Guide

I'm a software engineer and the founder of techsolutionstuff.com. Hailing from India, I craft articles, tutorials, tricks, and tips to aid developers. Explore Laravel, PHP, MySQL, jQuery, Bootstrap, Node.js, Vue.js, and AngularJS in our tech stack.

RECOMMENDED POSTS

FEATURE POSTS