You can clone with
If I run app/console doctrine:fixtures:load --purge-with-truncate I get the error SQLSTATE: Syntax error or access violation: 1701 Cannot truncate a table referenced in a foreign key constraint
app/console doctrine:fixtures:load --purge-with-truncate
SQLSTATE: Syntax error or access violation: 1701 Cannot truncate a table referenced in a foreign key constraint
This is a restriction in MySQL 5.5: it cannot truncate when there is a foreign key. This is exactly the reason why using TRUNCATE is not the default behavior anymore.
But can't you delete all data then TRUNCATE all tables and then importing all new datas?
This issue could be fixed by disabling the foreign key checks before truncating (SET foreign_key_checks = 0). Would that be an option worth thinking about? I don't know how other RDMS manage this issue...
@deeky666 this has already been suggested, and @beberlei rejected it.
doctrine:fixtures:load fails with foreign key errors for me either with or without the --purge-with-truncate option. Is this the same issue, or something deeper?
Foreign keys are also checked when truncating a table, thus it's the same problem...
Run into the same problem today. I would go for another option to disable foreign key checks for truncate.
Have we found a solution for this yet?
According to @guilhermeblanco this will be fixed in 2.0
Any news on this? why "SET foreign_key_checks = 0;" proposal has been rejected ?
I think SET foreign_key_checks = 0; it's the only possible way to solve this problem. That's why it exists. Because if you have a relation with foreign keys between each other, there is no other way.
So this command doesn't make sense at all to me. :(
Please see also the discussion here: doctrine/data-fixtures#127
So there is still no solution available for this problem? Even a hacky one?