1. There are existing tables raceinfo and groupinfo. The field race_id of table groupinfo is associated with the primary key of table raceinfo.
2. When using fzaninotto/Faker to fill data into table groupinfo, data filling failure will occur.
Question: How to solve the problem of foreign key association between two related tables and successfully fill in false data?
Just turn off the foreign key constraints before starting to fill in the data.
It doesn’t matter if the filling is completed or not. Closing constraints is only valid for the current database connection.
http://laravelacademy.org/pos...