I'm setting up a Symfony2 app and am trying to use Doctrine migrations. In this specific instance, I'm trying to add a new table, clients, for an entity, client, that I just created. This table does not exist in any form right now in the database.
When I run php app/console doctrine:migrations:diff, I get the following error:
[Doctrine\DBAL\Schema\SchemaException]
There is no column with name 'brand_id' on table 'clients'
Of course there is no column with that name, the table doesn't exist yet!
Shouldn't Doctrine recognize that there is no table and create it? For reference, here's my entity:
<?php
namespace RandomBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Client
*
* @ORM\Table(name="clients", indexes={@ORM\Index(name="brand_id", columns={"brand_id"})})
* @ORM\Entity
* @ORM\HasLifecycleCallbacks
*/
class Client
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, nullable=false)
*/
private $name;
/**
* @var \RandomBundle\Entity\Brand
*
* @ORM\ManyToOne(targetEntity="RandomBundle\Entity\Brand")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="brand_id", referencedColumnName="id")
* })
*/
private $brand;
/**
* @var \RandomBundle\Entity\Project
*
* @ORM\OneToMany(targetEntity="RandomBundle\Entity\Project", mappedBy="client")
*/
private $projects;
/**
* @var \DateTime
*
* @ORM\Column(name="updated_at", type="datetime", nullable=false)
*/
private $updatedAt;
/**
* Constructor
*/
public function __construct()
{
$this->projects = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* @param string $name
* @return Client
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set updatedAt
*
* @param \DateTime $updatedAt
* @return Client
*/
public function setUpdatedAt($updatedAt)
{
$this->updatedAt = $updatedAt;
return $this;
}
/**
* Get updatedAt
*
* @return \DateTime
*/
public function getUpdatedAt()
{
return $this->updatedAt;
}
/**
* Set brand
*
* @param \Ripplr3\RipplrBundle\Entity\Brand $brand
* @return Client
*/
public function setBrand(\RandomBundle\Entity\Brand $brand = null)
{
$this->brand = $brand;
return $this;
}
/**
* Get brand
*
* @return \RandomBundle\Entity\Brand
*/
public function getBrand()
{
return $this->brand;
}
/**
* Add projects
*
* @param \RandomBundle\Entity\Project $projects
* @return Client
*/
public function addProject(\RandomBundle\Entity\Project $projects)
{
$this->projects[] = $projects;
return $this;
}
/**
* Remove projects
*
* @param \RandomBundle\Entity\Project $projects
*/
public function removeProject(\RandomBundle\Entity\Project $projects)
{
$this->projects->removeElement($projects);
}
/**
* Get projects
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getProjects()
{
return $this->projects;
}
}
/*
. It means multiline comment started with/*
instead of/**
.