4
4
4sadly2021-08-07 14:53:09
Laravel
4sadly, 2021-08-07 14:53:09

How to remove ->onDelete('set null') in migration?

$table->foreignId('user_id')->nullable()->constrained('users')->onDelete('set null');


I have a user_id column with ->onDelete('set null'), but with softDelete, I don't want the column to be cleared
. How can I remove this or how can I remove "->onDelete('set null')" in a new migration?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gerasimov, 2021-08-07
@4sadly

With softDelete, the record is not deleted, only the deleted_at field is filled.
Therefore, the onDelete('set null') trigger does not fire and the value is not set to zero.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question