title: MySQL Doctrine2 mapping:convert and schema:update change key field attributes: error 1005
body: <p>I used the doctrine:mapping:convert command to reverse engineer the schema from an existing mysql database that was built using Doctrine 1.  The original database has integer key fields like:</p>
  
  <pre><code>`client_id` int(10) unsigned default NULL,
  KEY `FK_activity_client` (`client_id`),
  </code></pre>
  
  <p>and</p>
  
  <pre><code>`client_id` int(10) unsigned NOT NULL auto_increment,
  </code></pre>
  
  <p>After creating the entities I got code that looked like:</p>
  
  <pre><code>/**
   * @var \Client
   *
   * @ORM\ManyToOne(targetEntity="Client")
   * @ORM\JoinColumns({
   *   @ORM\JoinColumn(name="client_id", referencedColumnName="client_id")
   * })
   */
  private $client;
  </code></pre>
  
  <p>and</p>
  
  <pre><code>/**
   * @var integer
   *
   * @ORM\Column(name="client_id", type="integer", nullable=false)
   * @ORM\Id
   * @ORM\GeneratedValue(strategy="IDENTITY")
   */
  private $clientId;
  </code></pre>
  
  <p>So far so good, just what I'd expected.  I then made a small change to another unrelated entity and tried to run doctrine:schema:update. It made changes to the fields like:</p>
  
  <pre><code>ALTER TABLE activity CHANGE client_id client_id INT DEFAULT NULL, ...
  </code></pre>
  
  <p>and </p>
  
  <pre><code>ALTER TABLE activity ADD CONSTRAINT FK_AC74095A8DB60186 FOREIGN KEY (client_id) REFERENCES client (client_id);
  DROP INDEX UN_client ON client;
  ALTER TABLE client CHANGE client_id client_id INT AUTO_INCREMENT NOT NULL, ...
  </code></pre>
  
  <p>This changes the activity client_id to unsigned int(11) signed, and then tries to create a foreign key to the unsigned int(10). </p>
  
  <p>And we see our old friend Error 1005, MySQL's most friendly error message.</p>
  
  <p>Now I know a couple of workarounds so I have it working, I could either adjust the fields in the database to what Doctrine wants or turn off foreign key checks using:</p>
  
  <pre><code>SET foreign_key_checks = 0;
  </code></pre>
  
  <p>In this case those workarounds are fine.  My question is:</p>
  
  <p>Is there a way to make Doctrine use the field sizes and attributes of the database, remember them in the entity and not mess with them when it doesn't need to.  This could be important where the database is large and shared with other applications that have their own requirements for what those attributes should be.</p>