这个问题在这里已有答案:
我得到了错误:SQLSTATE [42000]:语法错误或访问冲突:1075表定义不正确;当我尝试迁移我的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');
});
}
根据文档:Auto-incrementing UNSIGNED INTEGER (primary key) equivalent column.
因此,当它将其设置为主键时,您只能使用$table->increments
标记一列。