4

here에서 언급 한 바와 같이, 마이그레이션
의 관계를 할 때 우리는 단어 cascade를 사용할 수 있지만 나는 그들이 다른 작업 deleting 또는 updating 외부 키에 대해 아무 말도하지 않았다 궁금해 약 onUpdateno action 단지 phpMyAdmin같은
다른 액션이 5.2

$table->foreign('user_id') 
    ->references('id')->on('users') 
    ->onDelete('set null'); 
    //->onDelete('set_null'); 
    //->onDelete('setNull'); 

또는 같은 일 :

그래서 나는 그런 일이 여부가 있는지 확실하지 않습니다

enter image description here


감사

답변

6

당신은 phpmyadmin에 이런 식으로 언급 한 모든 옵션을 수행 할 수 있습니다 당신은 같은 널 (NULL) 외래 키 필드를 설정 확인해야

$table->...->onDelete('CASCADE'); 
$table->...->onDelete('SET NULL'); 
$table->...->onDelete('RESTRICT'); 

// do not call the onDelete() method if you want the NO ACTION option. 

를 :

$table->...->unsigned()->nullable();