How to drop softDeletes from a table in a migration

0 votes

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?

Nov 23, 2020 in PHP by kartik
• 37,510 points
1,316 views

1 answer to this question.

0 votes

Hello,

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');
}
answered Nov 23, 2020 by Niroj
• 82,880 points

Related Questions In PHP

0 votes
1 answer

How to select all records from one table that do not exist in another table?

Hello @kartik, You can either do like this: SELECT ...READ MORE

answered Jul 21, 2020 in PHP by Niroj
• 82,880 points
51,686 views
0 votes
1 answer

How to see indexes for a database or table in MySQL?

Hello @kartik, To see the index for a ...READ MORE

answered Aug 18, 2020 in PHP by Niroj
• 82,880 points
146,029 views
0 votes
1 answer

How to move columns in a MySQL table?

Hello @kartik, If empName is a VARCHAR(50) column: ALTER ...READ MORE

answered Aug 19, 2020 in PHP by Niroj
• 82,880 points
2,415 views
0 votes
1 answer

How to delete a certain row from mysql table with same column values?

Hello @kartik, Add a limit to the delete query delete from orders where ...READ MORE

answered Aug 26, 2020 in PHP by Niroj
• 82,880 points
1,438 views
0 votes
1 answer

Uncaught Error: Bootstrap's JavaScript requires jQuery

Hello @kartik, You have provided wrong order for ...READ MORE

answered Apr 28, 2020 in JQuery by Niroj
• 82,880 points
22,449 views
0 votes
1 answer

How to make Bootstrap popover Appear/Disappear on hover instead of click?

Hello @kartik, Set the trigger option of the popover to hover instead ...READ MORE

answered May 12, 2020 in JQuery by Niroj
• 82,880 points
2,973 views
0 votes
1 answer

How to enable Bootstrap tooltip on disabled button?

Hii @kartik, You can wrap the disabled button ...READ MORE

answered May 12, 2020 in JQuery by Niroj
• 82,880 points
4,676 views
0 votes
1 answer

Error: cannot call methods on button prior to initialization; attempted to call method 'loading'

Hii @kartik, It's caused by jquery-ui and bootstrap-button ...READ MORE

answered May 12, 2020 in JQuery by Niroj
• 82,880 points
5,627 views
0 votes
1 answer

How to concatenate text from multiple rows into a single text string in SQL server?

Hello @kartik, Use COALESCE: DECLARE @Names VARCHAR(8000) SELECT @Names = ...READ MORE

answered Jul 21, 2020 in PHP by Niroj
• 82,880 points
2,792 views
0 votes
1 answer

How to drop a table if it exists?

Hello @kartik, No. That will drop the table only ...READ MORE

answered Jul 21, 2020 in PHP by anonymous
• 82,880 points
522 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP