How to drop softDeletes from a table in a migration

PhpDatabaseLaravelLaravel Migrations

Php Problem Overview


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 in my down() function, if I roll back the migration? Is there a built-in method to do this, or do I just manually delete the columns that get added?

Php Solutions


Solution 1 - Php

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');
}

Since Laravel 5.5, this information can be found in the documentation.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionmiken32View Question on Stackoverflow
Solution 1 - PhpÁlvaro GuimarãesView Answer on Stackoverflow