schmittjoh / JMSJobQueueBundle

Run and Schedule Symfony Console Commands as Background Jobs
http://jmsyst.com/bundles/JMSJobQueueBundle
335 stars 254 forks source link

Issue Purging DB W/Doctrine Fixtures #66

Open bassrock opened 10 years ago

bassrock commented 10 years ago

So I am using doctrine fixtures to pre-load my database with data and it seems that doctrine fixtures has trouble clearing the jms_jobs tables when there are relations.

Is it possible that it is the way the relations are setup in the JMS Bundle?

purging database

  [Doctrine\DBAL\DBALException]                                                                                                                                                             
  An exception occurred while executing 'DELETE FROM jms_jobs':                                                                                                                             

  SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (``.`jms_job_related_entities`, CONSTRAINT `FK_E956F4E  
  2BE04EA9` FOREIGN KEY (`job_id`) REFERENCES `jms_jobs` (`id`))     
digifish commented 10 years ago

I ran into the same issue with running a unit test and loading Doctrine fixtures. I created a little hack to disable foreign key checks with mysql

$this->em = $this->getContainer()->get('doctrine.orm.entity_manager');
$stmt = $this->em->getConnection()->prepare("SET FOREIGN_KEY_CHECKS=0");
$stmt->execute();