Skip to content
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

Foreign key constraints - Postgres #246

Closed
jbenezech opened this issue Oct 20, 2016 · 6 comments
Closed

Foreign key constraints - Postgres #246

jbenezech opened this issue Oct 20, 2016 · 6 comments

Comments

@jbenezech
Copy link

I have seen some fix and workarounds to solve the foreign key constraint problem with mysql but am using postgres and haven't found any easy way to bypass this.

My current workaround kind of works but make the test so slow they become unusable.

protected function fixturesLoad()
{
    $tool = new \Doctrine\ORM\Tools\SchemaTool(
         $this->getContainer()->get('doctrine')->getManager()
    );
    $tool->dropDatabase();
    $tool->createSchema($this->getContainer()->get('doctrine')->getManager()->getMetadataFactory()->getAllMetadata());

    return $this->loadFixtures(
@mikeSimonson
Copy link
Contributor

@jbenezech What issue are you referencing ?

@jbenezech
Copy link
Author

I think there are several pointing to the same problem: when there is a relationship between 2 entities as described below, when loading the fixtures and deleting the data, foreign key constraints are violated.

/**
* HarvestAnnouncement
* @ORM\Entity(repositoryClass="CRTP\HarvestBundle\Repository\HarvestAnnouncementRepository")
*/
class HarvestAnnouncement

    /**
    * @ORM\ManyToOne(targetEntity="CRTP\ProductBundle\Entity\SeedQuality")
    * @ORM\JoinColumn(name="seed_quality_id", referencedColumnName="id", nullable=false, onDelete="restrict")
    **/
    private $seedQuality;

This one for example, proposes a fix for mysql: #113

@devantoine
Copy link

I was about to open an issue for this exact same bug.
It happens since the 1.2.0, and it is probably caused by this commit: #222

Currently I'm setting the version to 1.1.1 to avoid this bug.

@mikeSimonson
Copy link
Contributor

@devantoine Can you check if you still have that issue with dev-master ? It should be fixed now. I f you confirm the fix then I will release 1.2.1

Thanks

@devantoine
Copy link

@mikeSimonson Yes, it's fixed! Thanks!

@mikeSimonson
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants