foreign key constraint is incorrectly formed laravel
When creating a new table in Laravel. A migration will be generated like:
$table->bigIncrements('id');
Instead of (in older Laravel versions:
$table->increments('id');
foreign key constraint is incorrectly formed laravel
When creating a new table in Laravel. A migration will be generated like:
$table->bigIncrements('id');
Instead of (in older Laravel versions:
$table->increments('id');
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://laravel.com/docs/6.x/migrations#foreign-key-constraints
For default migrations in older versions of Laravel use unsignedInteger() method:
$table->unsignedInteger('order_id');
Or:
$table->integer('order_id')->unsigned();
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us