title: Symfony2, Doctrine2 - force update - table already exists on many-to-many relation
body: <p>After I successfuly created TaskBundle with One-to-Many relation between category and tasks, now I'm trying to create a new TaskBundle with Many-to-Many relation. I get also problem with checking checkbox in this relation, but now it is not a primary problem (maybe after solving this). I deleted all tables, which is TaskBundle using and trying to create a new, but here is problem (description at the bottom). </p>
  
  <p>My Task object:</p>
  
  <pre><code>&lt;?php
  
  namespace Acme\TaskBundle\Entity;
  
  use Doctrine\ORM\Mapping as ORM;
  use Symfony\Component\Validator\Constraints as Assert;
  
  /**
   * @ORM\Entity
   * @ORM\Table(name="tasks") 
   */
  class Task
  {
      /**
       * @ORM\Id
       * @ORM\Column(type="integer")
       * @ORM\GeneratedValue(strategy="AUTO")
       */
      protected $id;              
  
      /**
       * @ORM\Column(type="string", length=200)    
       * @Assert\NotBlank(
       *      message = "Task is empty"      
       * )    
       * @Assert\Length(
       *      min = "3",
       *      minMessage = "Task is too short"         
       * )     
       */     
      protected $task;
  
      /**
       * @ORM\Column(type="datetime")    
       * @Assert\NotBlank()
       * @Assert\Type("\DateTime")
       */
      protected $dueDate;
  
      /**
       * @Assert\True(message = "You have to agree.")    
       */         
      protected $accepted;
  
      /**
       * @ORM\ManyToMany(targetEntity="Category", inversedBy="tasks")
       * @ORM\JoinTable(name="categories")                         
       */
      protected $category;
  
      /**
       * Constructor
       */
      public function __construct()
      {
          $this-&gt;category = new \Doctrine\Common\Collections\ArrayCollection();
      }
  
      /**
       * Get id
       *
       * @return integer 
       */
      public function getId()
      {
          return $this-&gt;id;
      }
  
      /**
       * Set task
       *
       * @param string $task
       * @return Task
       */
      public function setTask($task)
      {
          $this-&gt;task = $task;
  
          return $this;
      }
  
      /**
       * Get task
       *
       * @return string 
       */
      public function getTask()
      {
          return $this-&gt;task;
      }
  
      /**
       * Set dueDate
       *
       * @param \DateTime $dueDate
       * @return Task
       */
      public function setDueDate($dueDate)
      {
          $this-&gt;dueDate = $dueDate;
  
          return $this;
      }
  
      /**
       * Get dueDate
       *
       * @return \DateTime 
       */
      public function getDueDate()
      {
          return $this-&gt;dueDate;
      }
  
      /**
       * Add category
       *
       * @param \Acme\TaskBundle\Entity\Category $category
       * @return Task
       */
      public function addCategory(\Acme\TaskBundle\Entity\Category $category)
      {
          $this-&gt;category[] = $category;
  
          return $this;
      }
  
      /**
       * Remove category
       *
       * @param \Acme\TaskBundle\Entity\Category $category
       */
      public function removeCategory(\Acme\TaskBundle\Entity\Category $category)
      {
          $this-&gt;category-&gt;removeElement($category);
      }
  
      /**
       * Get category
       *
       * @return \Doctrine\Common\Collections\Collection 
       */
      public function getCategory()
      {
          return $this-&gt;category;
      }
  }
  </code></pre>
  
  <p>and Category object</p>
  
  <pre><code>&lt;?php
  
  namespace Acme\TaskBundle\Entity;
  
  use Doctrine\ORM\Mapping as ORM;
  use Symfony\Component\Validator\Constraints as Assert;
  
  /**
   * @ORM\Entity
   * @ORM\Table(name="categories") 
   */
  class Category
  {
      /**
       * @ORM\Id
       * @ORM\Column(type="integer")
       * @ORM\GeneratedValue(strategy="AUTO")             
       */
      protected $id; 
  
      /**
       * @ORM\Column(type="string", length=200, unique=true)   
       * @Assert\NotNull(message="Categories cannot be empty", groups = {"adding"})                   
       */         
      protected $name;  
  
      /**
       * @ORM\ManyToMany(targetEntity="Task", mappedBy="category")
       */
      private $tasks;            
  
  
      public function __toString()
      {
          return strval($this-&gt;name);
      }
      /**
       * Constructor
       */
      public function __construct()
      {
          $this-&gt;tasks = new \Doctrine\Common\Collections\ArrayCollection();
      }
  
      /**
       * Get id
       *
       * @return integer 
       */
      public function getId()
      {
          return $this-&gt;id;
      }
  
      /**
       * Set name
       *
       * @param string $name
       * @return Category
       */
      public function setName($name)
      {
          $this-&gt;name = $name;
  
          return $this;
      }
  
      /**
       * Get name
       *
       * @return string 
       */
      public function getName()
      {
          return $this-&gt;name;
      }
  
      /**
       * Add tasks
       *
       * @param \Acme\TaskBundle\Entity\Task $tasks
       * @return Category
       */
      public function addTask(\Acme\TaskBundle\Entity\Task $tasks)
      {
          $this-&gt;tasks[] = $tasks;
  
          return $this;
      }
  
      /**
       * Remove tasks
       *
       * @param \Acme\TaskBundle\Entity\Task $tasks
       */
      public function removeTask(\Acme\TaskBundle\Entity\Task $tasks)
      {
          $this-&gt;tasks-&gt;removeElement($tasks);
      }
  
      /**
       * Get tasks
       *
       * @return \Doctrine\Common\Collections\Collection 
       */
      public function getTasks()
      {
          return $this-&gt;tasks;
      }
  }
  </code></pre>
  
  <p>So, after i put <code>doctrine:schema:update --force</code> i'll get error: <code>Table 'symfony.categories' already exists</code>. I've tried to delete all caches, but same problem. Any idea?</p>
  
  <p>There's only problem, if it is as m2m relation.</p>
  
  <p><strong>PS</strong>: I was looking for this problem at the Google, but no one answers at this problem. There were only questions, but not correct answers, where the problem is and how to solve it.</p>