I have created categories table using categories migration and then i am trying to create products table using another migration with foreign key categories_id in products t
unsigned() should be defined while setting the type, not while setting the foreign key. Also, reference() should be references()
unsigned()
reference()
references()
The corresponding lines should be changed like this:
$table->integer('category_id')->unsigned(); $table->foreign('category_id')->references('id')->on('categories');