title: Laravel - add foreign key on existing table with data
body: <p>I have existing table <code>objects</code> with data. Now I need to add new table named <code>holdings</code> and add a relation from objects to <code>holdings</code> table. In the migration file, I print this:</p>
  
  <pre><code>$table-&gt;foreign('holding_id')-&gt;references('id')-&gt;on('holdings')-&gt;onDelete("NO ACTION");
  </code></pre>
  
  <p>and get this error when trying to migrate </p>
  
  <pre><code>SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update 
  a child row: a foreign key constraint fails (`kolomnaoffice`.`#sql-f10_126` 
  CONSTRAINT `objects_holding_id_foreign` FOREIGN KEY (`holding_id`) 
  REFERENCES `holdings` (`id`) ON DELETE NO ACTION) (SQL: alter table `objects` add constraint 
  `objects_holding_id_foreign` foreign key (`holding_id`) references `holdings` 
  (`id`) on delete NO ACTION)
  </code></pre>
  
  <p>I have correct database structure (both InnoDB), the fields exist and have correct type (int). The only thing different is that the table <code>objects</code> is filled with data, and table <code>holdings</code> is new and empty.</p>