Laravel迁移:从现有外键中删除onDelete('cascade') [英] Laravel migration : Remove onDelete('cascade') from existing foreign key
本文介绍了Laravel迁移:从现有外键中删除onDelete('cascade')的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经创建了这样的迁移:
I have created a migration like this :
// ...
$table->foreign('a')->references('b')->on('c')->onDelete('cascade');
// ...
我想在新迁移中删除onDelete('cascade')
而不会破坏任何内容.我该怎么办?
I want to remove the onDelete('cascade')
in a new migration without breaking anything. How can I do that ?
推荐答案
您可以尝试删除旧的外键并添加,然后添加一个不带onDelete
的新外键:
You can try to remove the old foreign key and add then add a new one without onDelete
:
$table->dropForeign('tablename_a_foreign');
$table->foreign('a')->references('b')->on('c');
这篇关于Laravel迁移:从现有外键中删除onDelete('cascade')的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文