In some versions of Laravel you need to specify the
$table->increments('id')->unsigned() to match the standard integer field
$table->integer('customer_id') because the increments was saved as INT(11) and the standard integer as INT(10).
I didn't had this problem with Laravel4.1
Thanks i changed that and now i get this error. Andy ideas?
SQLSTATE: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (
bbgapp.<result 2 when explaining filename '
customers_memberships_customers_id_foreign FOREIGN KEY (
id)) (SQL: alter table
customers_m emberships add constraint customers_memberships_customers_id_foreign foreign key (
id) on delete restrict) (Bindings: array
Looks like the
customer_id you're trying to insert doesn't exist.
Have you tired to create the foreign key wih empty tables ?
Okay i think i figure it out using this query on the database. Looks like there was a customers_id from a customer that didn't' exist anymore in the customers_memberships table. It was causing the constraint error.
select * from customers_memberships where customers_id not in (select id from customers);
Sign in to participate in this thread!
We'd like to thank these amazing companies for supporting us