miken32 miken32 - 6 months ago 26
PHP Question

How to drop softDeletes from a table in a migration

I'm adding the soft delete columns to my table in a migration:

public function up()
{
Schema::table("users", function ($table) {
$table->softDeletes();
});
}


But, how can I remove these if I roll back? Is there a method to do this, or do I just manually delete the columns that get added?

Answer

On your migration class:

public function down()
{
    Schema::table("users", function ($table) {
        $table->dropSoftDeletes();
    });
}

Illuminate\Database\Schema\Blueprint.php:

public function dropSoftDeletes()
{
    $this->dropColumn('deleted_at');
}