mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-1388: ORMPurger truncate fails for referenced tables in MySQL #1737
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (Sep 22, 2011).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user bubblez:
Running the doctrine:fixtures:load command in symfony2 invokes the doctrine ORMPurger, in my case for the MySQL platform, and throws following PDO Exception:
SQLSTATE[42000]: Syntax error or access violation: 1701 Cannot truncate a table referenced in a foreign key constraint (
sf2blog.comment, CONSTRAINTFK*9474526CDAE07E97FOREIGN KEY (blog*id) REFERENCESsf2blog.blog(id))That is because my comment table references the id column of the blog table and doctrine tries to truncate the blog table. To solve that you should run
SET foreign_key_checks=0;
prior to
TRUNCATE TABLE
blogand reactivate foreign key checks again
SET foreign_key_checks=0;
One way to achieve that would be to implement the getTruncateTableSQL method in the Doctrine\DBAL\Platforms\MySqlPlatform class.
@doctrinebot commented on GitHub (Sep 22, 2011):
Comment created by bubblez:
Added a patch with the changes suggested in the description.
@doctrinebot commented on GitHub (Oct 10, 2011):
Comment created by @beberlei:
This was fixed by going back to delete by using a commandline switch. I need to check for a better fix.
@doctrinebot commented on GitHub (Oct 10, 2011):
Issue was closed with resolution "Fixed"
@doctrinebot commented on GitHub (Dec 13, 2015):
Imported 1 attachments from Jira into https://gist.github.com/a710b259ee337f7fbda2