Laravel Database Schema, Nullable Foreign

前端 未结 4 820
自闭症患者
自闭症患者 2020-12-15 16:52

I\'ve these two database tables:

  1. User Tables
  2. Partner Tables

User Tables will handle this kind of informations

4条回答
  •  萌比男神i
    2020-12-15 17:18

    For Laravel 7.x I use this way:

    $table->bigInteger('word_type_id')->nullable()->unsigned();
    $table->index('word_type_id')->nullable();
    $table->foreign('word_type_id')->nullable()->references('id')->on('word_types')->onDelete('cascade');
    

提交回复
热议问题