创建迁移时,外键约束的格式不正确

时间:2019-07-01 14:55:46

标签: laravel-5.8

General error: 1005 Can't create table eapi .#sql-12e8_2 (errno: 150 "Foreign key constraint is incorrectly formed") (SQL: alter table产品add constraint products_user_id_foreign foreign key ( user_id ) references用户( id`)在删除级联上)

Schema::create('products', function (Blueprint $table) {
        $table->bigIncrements('id');
        $table->string('name');
        $table->integer('price');
        $table->text('details');
        $table->unsignedBigInteger('user_id');
        $table->foreign('user_id')->references('id')->on('user')->onDelete('cascade');
        $table->timestamps();
    });

0 个答案:

没有答案