I have created a migration like this :
// ...
$table->foreign('a')->references('b')->on('c')->onDelete('cascade');
// ...
I want to remove the onDelete('cascade')
in a new migration without breaking anything. How can I do that ?
Use the ON DELETE CASCADE option to specify whether you want rows deleted in a child table when corresponding rows are deleted in the parent table. If you do not specify cascading deletes, the default behavior of the database server prevents you from deleting data in a table if other tables reference it.
CASCADE in SQL is used to simultaneously delete or update an entry from both the child and parent table. The keyword CASCADE is used as a conjunction while writing the query of ON DELETE or ON UPDATE.
You can try to remove the old foreign key and add then add a new one without onDelete
:
$table->dropForeign(['a']);
$table->foreign('a')->references('b')->on('c');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With