SQLSTATE [42000]:语法错误或访问冲突:1075表定义不正确;只能有一个自动列,必须将其定义为键“[重复]

问题描述 投票:-2回答:1

我得到了错误: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');
    });
}
mysql sql laravel migrate
1个回答
0
投票

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

Documentation

© www.soinside.com 2019 - 2024. All rights reserved.