Mysql SQLSTATE[42000]:语法错误或访问冲突:1075不正确的表定义;只能有一个自动列,必须将其定义为键;
我发现了一个错误: SQLSTATE[42000]:语法错误或访问冲突:1075不正确的表定义;只能有一个自动列,必须将其定义为键“) 当我尝试迁移我的laravel db时。这是我的模式Mysql SQLSTATE[42000]:语法错误或访问冲突:1075不正确的表定义;只能有一个自动列,必须将其定义为键;,mysql,sql,laravel,migrate,Mysql,Sql,Laravel,Migrate,我发现了一个错误: SQLSTATE[42000]:语法错误或访问冲突:1075不正确的表定义;只能有一个自动列,必须将其定义为键“) 当我尝试迁移我的laravel db时。这是我的模式 Schema::create('estoques', function (Blueprint $table) { $table->increments('id_loja')->unsigned(); $table->increments('id_pro
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');
});
}
根据文档:
自动递增无符号整数(主键)等效列。
因此,当它将其设置为主键时,只能有一列标记为$table->increments