首页 > 解决方案 > 不能在 laravel 8 上使用 onUpdate 方法

问题描述

Schema::create('posts', function (Blueprint $table) {
    $table->id();
    $table->foreignId('author')->constrained('users')->onDelete('cascade')->onUpdate('cascade');
    $table->timestamps();
});

onUpdate 没用??

标签: sqllaravel-8

解决方案


请像这样检查。

$table->foreignId('author')->constrained()
      ->onUpdate('cascade')
      ->onDelete('cascade');

推荐阅读