errno:150 foreign key constrait is incorrectly formed laravel code example
Example: errno: 150 foreign key constraint is incorrectly formed laravel 8
Since increments() creates an unsigned integer column, you need to define the foreign key column as unsigned integer too.
Default migrations in Laravel 6+ use bigIncrements(), so you need to use unsignedBigInteger() method:
$table->unsignedBigInteger('order_id');
https:
For default migrations in older versions of Laravel use unsignedInteger() method:
$table->unsignedInteger('order_id');
Or:
$table->integer('order_id')->unsigned();