Skip to content
Advertisement

SQLSTATE[HY000]: General error: 1005 Can’t create table – Laravel 4

I get this error when I do php artisan migrate. Is there something wrong in my migration files? Or is it possible my models are wrong coded? But the migrations should work even there is something wrong in the models?

JavaScript

gigs migration

JavaScript

bands migration

JavaScript

Model Band

JavaScript

Model Gig

JavaScript

Advertisement

Answer

You must first create the table, then create the foreign keys:

JavaScript

And your bands table should migrate first, since the gigs is referencing it.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement