I have a simple table for recursive categories:
id name parent_id - is a link to id, NULL - for root categories I need to create a table with foreign key. My class doesn't create this key. How can I change this class to create table with foreign key using "doctrine:schema:create"? What I have tried:
<?php namespace Test\BackEndBundle\Entity; use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity * @ORM\Table(name="category") */ class Category { /** * @ORM\Id * @ORM\Column(type="bigint", length=20) * @ORM\GeneratedValue(strategy="AUTO") * @var int */ protected $id; /** * @ORM\Column(type="string", length="255") * @var string */ protected $name; /** * @ORM\Column(name="parent_id", type="bigint", length=20, nullable="true") * @ORM\OneToMany(targetEntity="Category") * @ORM\JoinColumn(name="id", onDelete="CASCADE", onUpdate="CASCADE") * @var int */ protected $parentId; /** * Get id * * @return int */ public function getId() { return $this->id; } /** * Set name * * @param string $name */ public function setName($name) { $this->name = $name; } /** * Get name * * @return string */ public function getName() { return $this->name; } }