title: Symfony 2 Doctrine constrain foreign key issue with the mysql Database
body: <p>I am trying to create a one to many relationship between Vehicle and job as follows:
      
  
  <pre><code>use Doctrine\ORM\Mapping as ORM;
  
  
  /**
   * @ORM\Entity
   * @ORM\Table(name="job")
   */
  class Job
  {
  /**
   * @ORM\Column(type="integer", name="id_vehicle")
   * @ORM\Id
   * @ORM\GeneratedValue(strategy="AUTO")
   */
  protected $idJob;
  /**
   * @ORM\Column(type="string", length=20, name="delivery_number")
   */
  protected $deliveryNo; 
  /**
   * @ORM\Column(type="datetime", name="date_time")
   */
  protected $dateTime;
  /**
   * @ORM\Column(type="string", length=200, name="destination")
   */
  protected $destination;      
  /**
   * @ORM\Column(type="integer", name="km_odo_start", nullable=true)
   */    
  protected $kmOdoStart;   
  /**
   * @ORM\Column(type="integer", name="km_odo_end", nullable=true)
   */    
  protected $kmOdoEnd;      
  /**
   * @ORM\Column(type="string", length=50, name="deliveryType", nullable=true)
   */
  protected $deliveryType;
  /**
   * @ORM\Column(type="integer", name="fuel_used", nullable=true) 
   */
  protected $fuelUsedLitre;
  /**
   * @ORM\Column(type="string", length=100, name="driver_name", nullable=true)
   */    
  protected $driverName;
  /**
   * @ORM\Column(type="string", length=250, name="crew_names", nullable=true)
   */    
  protected $crewNames;
  /**
   * @ORM\Column(type="string", length=7, name="triler_plate_number", nullable=true)
   */
  protected $trilerPlateNumber;
  /**
   * @ORM\Column(type="string", length=500, name="remarks")
   */
  protected $remarks;
  /**
   * @ORM\Column(type="string", length=500, name="return_load_plan")
   */
  protected $returnLoadPlan;
  /**
  * @ORM\ManyToOne(targetEntity="Vehicle", inversedBy="job")
  * @ORM\JoinColumn(name="id_vehicle", referencedColumnName="idVehicle")
  */
  protected $idVehicle;    
  }
  </code></pre>
  
  <p>And the vehicle:
      
  
  <pre><code>use Doctrine\ORM\Mapping as ORM;
  use Doctrine\Common\Collections\ArrayCollection;
  /**
   * @ORM\Entity
   * @ORM\Table(name="vehicle")
   */
  
  class Vehicle
  {
  /**
   * @ORM\Column(type="integer", name="id_vehicle")
   * @ORM\Id
   * @ORM\GeneratedValue(strategy="AUTO")
   */
  protected $idVehicle;
  /**
   * @ORM\Column(type="string", length=7, name="plate_number")
   */
  protected $plateNumber;
  
  /**
   * @ORM\Column(type="integer", name="distance_to_service")
   */ 
  protected $DistanceToServiceKm;
  /**
   * @ORM\Column(type="integer", name="last_service_odo")
   */ 
  protected $lastServiceODOKm; 
  /**
   * @ORM\Column(type="string", length=100, name="make")
   */
  protected $makeName;   
  /**
   * @ORM\Column(type="string", length=100, name="model")
   */
  protected $modelName;
  
  /**
  * @ORM\OneToMany(targetEntity="Job", mappedBy="vehicle")
  */
  protected $jobs;
  
  public function __construct()
  {
      $this-&gt;jobs = new ArrayCollection();
  } 
  </code></pre>
  
  <p>When I try to run:</p>
  
  <pre><code>PS D:\web\wamp\www\team&gt; php app/console doctrine:schema:update --force
  Updating database schema...
  
    [Doctrine\DBAL\DBALException]
    An exception occurred while executing 'ALTER TABLE job ADD CONSTRAINT FK_FBD8E0F8C51D4DF6 FOREIGN KEY (id_vehicle)
    REFERENCES vehicle (idVehicle)':
  
    SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint
  
  
    [PDOException]
    SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint
  
  
  
  doctrine:schema:update [--complete] [--dump-sql] [--force] [--em[="..."]]
  
  
  PS D:\web\wamp\www\team&gt; 
  </code></pre>
  
  <p>Then the <code>--dump-sql</code> generates good MySQL code.
  What do you think is happening? I this a bug or I am making a mistake? I have seen a few threads like this, but none of the things I've seen works for me. any help will be appreciated.
  Regards</p>