-
-
Notifications
You must be signed in to change notification settings - Fork 223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Truncating table with foreign keys fails #17
Comments
The issue with using |
Ok, but the issue with If it's really needed, starting auto increment from 1 can be always done for example by dropping and recreating tables, right? |
Yep - I've got this issue too. Rolling back to 91ff6eb for now. |
+1 for reverting 91ff6eb |
Why not just add 'CASCADE' to the TRUNCATE? $platform->getTruncateTableSQL($tbl) has a second parameter that would return something like 'TRUNCATE table CASCADE' (at least for postgres it does) and with that it works. |
How about adding a pull request? I can merge it then. |
@leahaense The issue still exists when using MySQL (even after 4a8464e). |
In that case your foreign keys are bi-directional or something? |
@beberlei yes I think so. I am not 100% sure as SQL is generated by Doctrine from one-to-many/many-to-many annotations (which yes are bi-directional). Anyone else is having this issue on MySQL? Or is it just me? |
Can you do foreign_key_checks=0 before TRUNCATE ? http://bugs.mysql.com/bug.php?id=58788 I'm also hitting this issue |
I've ran with the exact same issue with my partner, this does happen on MySQL 5.5 while 5.1 is fine with truncating tables with foreign keys. Reverting back to DELETE wouldn't be an elegant solution as stated before with the auto_increment keys not resetting. |
Would be nice if there could come a fix like foreign_key_checks=0 for mysql 5.5 |
Here is a quick dirty hack for getting it to work with MySQL 5.5
|
The above fix works great for me. Any ideas when a fix could be introduced to repo so i dont have to change it manually all the time? |
I also had to add this fix to use the bundle. |
The above fixed it for me (as far as I can tell, still learning Doctrine/Symfony2) |
I made the |
Same problem on my machine with MySQL 5.5.9, however dogbrain's hack helped. |
Can we get this fix integrated please? Otherwise everyone always has to add it manually to get it working. |
Its not a "fix" its a hack. I wont merge a hack. |
Ok... fair enough. However, it's a hack that allows the fixtures to work and it would be nice if they did ;) |
I'm not sure I'm doing it right, however I have the same problem. I can't figure out what version I'm using, I've downloaded with composer with
Anyway, in order to obtain an index reset, I need to run "doctrine:schema:drop --force" and then "doctrine:schema:update --force" before reloading. Otherwise I have the same error. Can someone pls tell me what I'm doing wrong? |
I'm having the same issue running the latest version of doctrine fixtures and Mysql 5.5. The "hack" worked, but that's not a portable solution. I have to drop the schema and recreate it every time. |
Do yourself a favor and create a script inside Symfony folder, like
Run |
When I am calling symfony CLI command:
I get
Table symfony.param_product is created by @Orm\JoinTable annotation (with @Orm\ManyToMany). I am using MySQL
This worked fine before this change: 91ff6eb
I thought it might be bug on my side (e.g. no onDelete options) but everything I tried failed.
As far as I learned e.g. from http://forums.asp.net/t/1283840.aspx/1?How+can+I+truncate+the+table+which+have+foreign+key+
So it seems to me the only solution is to use DELETE or drop the foregin keys first.
Can we revert the 91ff6eb change to fix this problem? @beberlei?
The text was updated successfully, but these errors were encountered: