-
-
Notifications
You must be signed in to change notification settings - Fork 203
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
doctrine:fixtures:load --purge-with-truncate fails #50
Comments
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... |
|
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? |
Maybe I'm late, but I found this to be a workding workaround: |
Can we please add something like --ignore-foreign-keys so that I don't have to edit the core? |
@afilina "ignoring" foreign keys is a MySQL specific option which is not in that way available for other database vendors. Adding a MySQL specific option to data fixtures is not a good solution and won't happen. |
Fall into same issue today. Simply wasted time to resolve this manually. Mentioned "ignoring" flag could be abstraction for other rdbms and native for mysql. |
'Hi guys' ^^ is there anything new ? ty |
Hi, same question as rudak - thank you! |
This still is an issue that is not easy to solve across vendors. At least with the current development stage of DBAL. I had been working on something but haven't gotton to finish it. So "no" there is nothing new yet. |
You can actually execute this command :
|
Same problem, i run a to solve (if it is a solution)... |
This seems to be doing the job for me as a runtests.sh script:
|
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
|
This seems to be shorter
|
If I run
app/console doctrine:fixtures:load --purge-with-truncate
I get the errorSQLSTATE[42000]: Syntax error or access violation: 1701 Cannot truncate a table referenced in a foreign key constraint
The text was updated successfully, but these errors were encountered: