Я пытаюсь перенести две таблицы в LaravelLaravel Миграция - не может добавить внешний ключ
Таблица 'Aitems'
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateAitemsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
//
Schema::create('aitems', function($table) {
$table->engine = 'InnoDB';
$table->increments('id');
$table->integer('item_id');
$table->integer('listing_id');
$table->string('item_category');
$table->string('item_name');
$table->string('item_price');
$table->string('item_description');
$table->string('item_storing_address_1');
$table->string('item_storing _address_2');
$table->string('item_storing_suburb');
$table->string('item_addr_long');
$table->string('item_addr_lang');
$table->timestamps();
});
Schema::table('aitems', function($table){
$table->foreign('item_id')->references('item_id')->on('itemfeatures');
$table->foreign('listing_id')->references('listing_id')->on('itemfeatures');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
Schema::drop('aitems');
}
}
стол 'itemfeatures'
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateItemfeaturesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
//
Schema::create('itemfeatures', function(Blueprint $table) {
$table->engine = 'InnoDB';
$table->increments('id');
$table->integer('listing_id')->unsigned();
$table->integer('item_id')->unsigned();
$table->string('feature_id');
$table->string('feature_description');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
Schema::drop('itemfeatures');
}
}
При попытке выполнить миграцию я получил сообщение об ошибке 1215 Не могу добавить ограничение внешнего ключа. Заглянули во многие другие форумы и до сих пор не могу понять, что я сделал неправильно. Очень ценили любую помощь там. Благодарю.