Support the ongoing development of Laravel.io →
posted 10 years ago
Database
Last updated 2 years ago.
0

Possible solutions but not sure:

  1. Database tables should be using InnoDB engine.
  2. The migrations should run in right order : the migration for creating the parent table should run first.
  3. Both the relating keys should use a same data type.
Last updated 2 years ago.
0

Try

$table->unsignedInteger('user_id');

instead of

$table->integer('user_id')->unsigned();
Last updated 2 years ago.
0

Thanks bro, helped me as well!

Last updated 2 years ago.
0

Maybe you trying add a foreign key to the users table, before the users table is created?

Last updated 2 years ago.
0

For those folks who wander here from Google, don't forget to put

...
$table->engine = InnoDB; 
...

into both migrations!

Last updated 8 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

JeffreyR jeffreyr Joined 11 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.