I'm trying to create the following two tables with 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);
});
But it generates the following error:
General error: 1005 Can't create table 'orders' (errno: 150 "Foreign key constraint is incorrectly formed")
I can not find the problem. Thank you very much.