How to drop softDeletes from a table in a migration
Stefan Bogdanescu
Founder & Senior Architect · 2026-06-29
How to Safely Drop softDeletes Columns in Your Laravel Migrations
As developers building robust applications with Laravel, managing database schema changes through migrations is a daily task. One feature that often prompts questions during rollback procedures is handling framework-added columns, such as those introduced by Eloquent's SoftDeletes trait.
I frequently encounter scenarios where I add a columnâlike the deleted_at timestamp required for soft deletionâand then need to roll back that migration. The core dilemma is: how do I ensure the down() method correctly reverses the operation without causing database errors or data loss?
Letâs dive into the specific challenge of dropping the softDeletes column when rolling back a migration.
Understanding Migration Rollbacks
When you execute php artisan migrate:rollback, Laravel executes the down() method defined in the reverse order of the migrations that were just run. If a migration only deals with adding a column, the down() method must contain the precise instruction to remove that change.
The specific scenario you presented involves using Schema::table() to add a column:
public function up()
{
Schema::table("users", function ($table) {
$table->softDeletes(); // This adds the deleted_at timestamp column
});
}The challenge arises because Laravelâs abstraction layer for softDeletes() doesn't inherently provide a simple softDeletes()->remove() method within the migration context. Therefore, manual intervention in the down() function is necessary.
The Solution: Manually Reversing Schema Changes
There is no single built-in method provided by Laravel to automatically reverse framework additions during a rollback. Instead, we must manually define the inverse operation in the down() method. Since adding softDeletes() effectively adds a column (usually named deleted_at), rolling back requires dropping that exact column.
Here is how you correctly implement the rollback for your migration:
public function down()
{
Schema::table("users", function ($table) {
// We explicitly drop the softDeletes column added during the 'up' phase.
$table->dropColumn('deleted_at');
});
}Why This Approach Works
When you use Schema::table() to call $table->softDeletes(), Laravel generates an actual ALTER TABLE command on your database to add the necessary column (typically named deleted_at). To successfully roll back this, the down() method must execute the exact inverse command: DROP COLUMN.
By explicitly targeting the generated column name (deleted_at), you ensure that when you rollback, the database schema reverts cleanly. This practice is fundamental to maintaining data integrity across your migrations, which is a core principle of good Laravel development, as emphasized by resources like those found on the official Laravel documentation.
Best Practices for Schema Management
When dealing with framework features that modify tables, always treat them as explicit schema changes within your migration file. This keeps the history transparent and ensures predictable rollbacks.
- Be Explicit: Never rely on implicit behavior during a rollback. Always define the exact SQL operation you expect to run in both
up()anddown(). - Naming Consistency: Ensure you know the exact column name created by the framework (in this case,
deleted_at) so yourdropColumncommand is precise. - Testing: Always test your migrations thoroughly. Use a local database instance to simulate rollbacks frequently. This prevents unexpected failures in production environments where manual intervention is impossible.
Conclusion
In summary, while Laravel provides powerful tools for schema management, framework-added features require careful handling during migration rollbacks. For removing columns added by traits like SoftDeletes, the developer must explicitly define the dropColumn operation within the down() method of the migration. This ensures that your database state is perfectly managed, allowing you to maintain clean and reliable application deployments.