Closed
Description
Hi,
i have updatet my laravel 4 and was running in an db:seed problem in:
laravel/framework/src/Illuminate/Database/Seeder.php:62
$connection->table($table)->truncate();
Thats the death if you working with a bunch of foreign key constrains.
Why you dont leave the delete? Is it for the AI reset?
In my case db:seed ends in an ->
[Exception]
SQLSTATE[42000]: Syntax error or access violation: 1701 Cannot truncate a table referenced in a foreign key constraint (`dbname`.`table2`, CONSTRAINT `fk_table2_table1
` FOREIGN KEY (`t1colum1`) REFERENCES `dbname`.`table1` (`colum1`)) (SQL: truncate `table1`) (Bindings: array (
))
Maybe its possible to give the seed file options for they should leave, delete or truncate the table/data.
array(
'table' => 'mytable',
'delete' => 'false/true/truncate',
#is the truncate for reset AI maybe this also an possible way to reset correct
'resetAI' => 3000, //ALTER TABLE foo AUTO_INCREMENT = 3000
short fix for all with the same troubles is to replace
#in file
laravel/framework/src/Illuminate/Database/Seeder.php:62
#the
$connection->table($table)->truncate();
#with
$connection->table($table)->delete();
thanks for your work,
ng
moxx
Metadata
Metadata
Assignees
Labels
No labels