SQLSTATE [42000]:语法错误或访问冲突:1075不正确的表定义;默认值为0。只能有一个自动列,并且必须将其定义为键”

时间:2019-03-16 01:07:26

标签: mysql sql laravel migrate

出现错误: SQLSTATE [42000]:语法错误或访问冲突:1075不正确的表定义;默认值为0。只能有一个自动列,并且必须将其定义为键”) 当我尝试迁移laravel db时,这里是我的架构...

    Schema::create('estoques', function (Blueprint $table) {
        $table->increments('id_loja')->unsigned();
        $table->increments('id_produto')->unsigned();

        $table->integer('quantidade');
        $table->timestamps();
        $table->softDeletes();
    });

    Schema::table('estoques', function($table) {
        $table->foreign('id_loja')->references('id')->on('lojas');
        $table->foreign('id_produto')->references('id')->on('products');
    });
}

1 个答案:

答案 0 :(得分:0)

根据文档:Auto-incrementing UNSIGNED INTEGER (primary key) equivalent column.因此,由于将其设置为主键,因此您只能将一列标记为$table->increments

Documentation