-2

Ive got the error: SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table definition; there can be only one auto column and it must be defined as a key") when i try to migrate my laravel db .Heres my schema...

    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 Answers1

0

As per the documentation: Auto-incrementing UNSIGNED INTEGER (primary key) equivalent column. Therefore as it's setting it as the primary key you can only have one column marked with $table->increments.

Documentation

Tim Rowley
  • 420
  • 4
  • 15