sneas
sneas

Reputation: 1062

Doctrine 2: Tree - Nestedset and InnoDB

I'm using Doctrine's 2 Tree-Nestedset extension with MySQL InndoDB database.

The yml table schema looks like this:

Ext\Entity\PageElement:
  type: entity
  table: page_element
  repositoryClass: Gedmo\Tree\Entity\Repository\NestedTreeRepository
  gedmo:
    tree:
      type: nested
  id:
    id:
      type: integer
      generator:
        strategy: AUTO
  fields:
    element_object_data:
      type: array
      nullabe: true
    element_object_type:
      type: string
      nullable: true
    lft:
      type: integer
      gedmo:
        - treeLeft
    rgt:
      type: integer
      gedmo:
        - treeRight
    root:
      type: integer
      gedmo:
        - treeRoot
    lvl:
      type: integer
      gedmo:
        - treeLevel
    sort_order:
      type: integer
      nullable: true
    created:
      type: datetime
      gedmo:
        timestampable:
          on: create
    updated:
      type: datetime
      gedmo:
        timestampable:
          on: update
  manyToOne:
    parent:
      targetEntity: Ext\Entity\PageElement
      inversedBy: children
      gedmo:
        - treeParent
  oneToMany:
    children:
      targetEntity: Ext\Entity\PageElement
      mappedBy: parent

Trying to delete any node containing children I get mysql error:

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (page_element, CONSTRAINT page_element_ibfk_1 FOREIGN KEY (parent_id) REFERENCES page_element (id))

I understand it is because of InnoDB reference restrictions but I'm not sure how to avoid it?

Upvotes: 2

Views: 1474

Answers (1)

Gediminas
Gediminas

Reputation: 878

Answer is on github issue tracker

Upvotes: 3

Related Questions