DoctrineFixturesBundle: doctrine:fixtures:load --purge-with-truncate fails
If I run app/console doctrine:fixtures:load --purge-with-truncate
I get the error SQLSTATE[42000]: Syntax error or access violation: 1701 Cannot truncate a table referenced in a foreign key constraint
About this issue
- Original URL
- State: closed
- Created 12 years ago
- Comments: 25 (9 by maintainers)
This seems to be shorter
You can actually execute this command :
I created a custom command for doing that , although updating schema every time it is a little bit frustrating.
Creating directory Command inside AppBundle
And run the command from terminal
php bin/console app:fixturesReload
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. 😦
Can we please add something like --ignore-foreign-keys so that I don’t have to edit the core?
Same problem, i run a
$ php bin/console doctrine:database:drop --force
$ php bin/console doctrine:database:create
$ php bin/console doctrine:schema:update --force
to solve (if it is a solution)…
This seems to be doing the job for me as a runtests.sh script:
Maybe I’m late, but I found this to be a workding workaround:
https://coderwall.com/p/staybw/workaround-for-1701-cannot-truncate-a-table-referenced-in-a-foreign-key-constraint-using-doctrine-fixtures-load-purge-with-truncate