Laravel:$ table-> primary在创建外键时会做些什么

时间:2017-10-18 02:32:09

标签: php mysql laravel

我发现像zizaco委托的一些迁移文件确实在其外键上有$ table-> primary,根据Define page layouts with XAML它说Add composite keys。它是什么意思,它的作用是什么。

Schema::create('sub_folders', function (Blueprint $table) {
    $table->increments('sf_id');

    $table->integer('fid')->unsigned();
    $table->foreign('fid')->references('fid')
          ->on('folders')
          ->onUpdate('cascade')
          ->onDelete('cascade');

    $table->string('sub_folder_name', 350);
    $table->string('sub_folder_display_name', 450);
    $table->text('sub_folder_description');
    $table->integer('content_count')->unsigned();
    $table->timestamps();

    $table->primary(['fid']);
});

0 个答案:

没有答案