Estoy intentando crear las siguientes dos tablas con Laravel:
Schema::create('orders', function (Blueprint $table) {
$table->bigIncrements('id');
$table->primary('id');
$table->bigInteger('numPedido')->unsigned();
$table->string('name', 300);
$table->string('business', 300)->nullable();
$table->string('dni', 20);
$table->string('phone', 20);
$table->string('address', 300);
$table->string('cp', 10);
$table->string('town', 100);
$table->string('city', 100);
$table->string('email', 300);
$table->timestamps();
});
Schema::create('order_items', function (Blueprint $table) {
$table->bigIncrements('id');
$table->primary('id');
$table->bigInteger('order_numPedido')->unsigned();
$table->foreign('order_numPedido')
->references('numPedido')
->on('orders')
->onDelete('cascade');
$table->string('name', 300);
$table->string('quantity', 5);
$table->string('import', 10);
});
Pero me genera el siguiente error:
General error: 1005 Can't create table `orders` (errno: 150 "Foreign key constraint is incorrectly formed")
No consigo dar con el problema. Muchas Gracias.