How to drop softDeletes from a table in a migration
25,426
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.
Related videos on Youtube
Author by
miken32
Programmer since (in a manner of speaking) 1988, systems and network administrator, open source contributor, old guy. He/him.
Updated on July 09, 2022Comments
-
miken32 almost 2 years
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? -
miken32 almost 8 yearsThanks; is there any actual API documentation that you used to find this? I'm using the docs at laravel.com/docs/5.2 which gives a good overview, but doesn't list every available method.
-
Álvaro Guimarães almost 8 yearsYou better navigate through the core classes. The documentation is always lacking some sugar.
-
Yevgeniy Afanasyev over 7 yearsOMG, after dropSoftDeletes - we are going to have a mess of historical and actual records together...
-
Jquestions over 5 yearsUpdating Laravel framework files is not a good move?! What about updates, etc?
-
Elijah Lofgren over 3 yearsdropSoftDeletes() already exists in Illuminate\Database\Schema\Blueprint.php (at least as of Laravel 8.12) so no updating of framework files is necessary.
-
Álvaro Guimarães over 3 yearsThey were always there, just not in the docs. And I never suggested editing framework files, please don't do it @Jquestions