DDC-3105: Doctrine Console Error (ORMPurger) #3854

Closed
opened 2026-01-22 14:29:09 +01:00 by admin · 4 comments
Owner

Originally created by @doctrinebot on GitHub (Apr 29, 2014).

Originally assigned to: @Ocramius on GitHub.

Jira issue originally created by user inhack20:

In symfony2 the command doctrine:fixtures:load Fails One-To-Many, Self-referencing using Doctrine\Common\DataFixtures\Purger\ORMPurger in example:

class DescriptionArea
{ 
//..
/****
* @ORM\OneToMany(targetEntity="DescriptionArea", mappedBy="parent")
*/
protected $descriptionAreas;

/****
 * @ORM\ManyToOne(targetEntity="DescriptionArea", inversedBy="descriptionAreas")
 */
protected $parent;
//..
}
Throw error:
[Doctrine\DBAL\DBALException]

An exception occurred while executing 'DELETE FROM prefix_DescriptionArea':

SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (sigtec*dev.prefix*DescriptionArea,

CONSTRAINT FK*7265873E727ACA70 FOREIGN KEY (parent_id) REFERENCES prefix*DescriptionArea (id))

Before running the query should delete the index when the table has self-reference.

Originally created by @doctrinebot on GitHub (Apr 29, 2014). Originally assigned to: @Ocramius on GitHub. Jira issue originally created by user inhack20: In symfony2 the command doctrine:fixtures:load Fails One-To-Many, Self-referencing using `Doctrine\Common\DataFixtures\Purger\ORMPurger` in example: ``` php class DescriptionArea { //.. /**** * @ORM\OneToMany(targetEntity="DescriptionArea", mappedBy="parent") */ protected $descriptionAreas; /**** * @ORM\ManyToOne(targetEntity="DescriptionArea", inversedBy="descriptionAreas") */ protected $parent; //.. } ``` ``` Throw error: [Doctrine\DBAL\DBALException] An exception occurred while executing 'DELETE FROM prefix_DescriptionArea': SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (sigtec*dev.prefix*DescriptionArea, CONSTRAINT FK*7265873E727ACA70 FOREIGN KEY (parent_id) REFERENCES prefix*DescriptionArea (id)) ``` Before running the query should delete the index when the table has self-reference.
admin added the Duplicate label 2026-01-22 14:29:09 +01:00
admin closed this issue 2026-01-22 14:29:09 +01:00
Author
Owner

@DannyvdSluijs commented on GitHub (Feb 4, 2016):

I'm having the same for but not or a self referencing relation.

/**
 * @ORM\OneToMany(targetEntity="Person", mappedBy="organisationalUnit")
 **/
private $persons;

/**
 * @ORM\ManyToOne(targetEntity="OrganisationalUnit", inversedBy="persons")
 * @ORM\JoinColumn(name="organisational_unit_id",  nullable=false)
 */
private $organisationUnit;
@DannyvdSluijs commented on GitHub (Feb 4, 2016): I'm having the same for but not or a self referencing relation. ``` php /** * @ORM\OneToMany(targetEntity="Person", mappedBy="organisationalUnit") **/ private $persons; /** * @ORM\ManyToOne(targetEntity="OrganisationalUnit", inversedBy="persons") * @ORM\JoinColumn(name="organisational_unit_id", nullable=false) */ private $organisationUnit; ```
Author
Owner

@Ocramius commented on GitHub (Feb 4, 2016):

To be tracked in doctrine/data-fixtures#127 instead.

Closing as duplicate

@Ocramius commented on GitHub (Feb 4, 2016): To be tracked in doctrine/data-fixtures#127 instead. Closing as duplicate
Author
Owner

@DannyvdSluijs commented on GitHub (Feb 4, 2016):

Actually mine fails with Postgres 9.4.5 and not with MySQL.

@DannyvdSluijs commented on GitHub (Feb 4, 2016): Actually mine fails with Postgres 9.4.5 and not with MySQL.
Author
Owner

@Ocramius commented on GitHub (Feb 4, 2016):

@DannyvdSluijs consider looking into the doctrine/data-fixtures issue tracker first anyway :)

@Ocramius commented on GitHub (Feb 4, 2016): @DannyvdSluijs consider looking into the doctrine/data-fixtures issue tracker first anyway :)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#3854