title: Strange foreign key issue with MySQL 5.5.9
body: <p>I'm experiencing a rather strange problem with foreign keys, namely this doesn't work as expected:</p>
  
  <pre><code>ALTER TABLE contact_contactlist 
    ADD FOREIGN KEY (contact_id) REFERENCES contacts(id) ON DELETE CASCADE;
  
  ALTER TABLE contact_contactlist 
    ADD FOREIGN KEY (contactlist_id) REFERENCES contactLists(id) ON DELETE CASCADE;
  
  ALTER TABLE contactLists 
    ADD FOREIGN KEY (owner_id) REFERENCES serviceAccounts(id);
  </code></pre>
  
  <p>(auto-generated by Doctrine 2)</p>
  
  <p>Yet, this works perfectly:</p>
  
  <pre><code>ALTER TABLE `contact_contactlist`
    ADD CONSTRAINT `contact_contactlist_ibfk_5` 
      FOREIGN KEY (`contact_id`) REFERENCES `contacts` (`id`) ON DELETE CASCADE,
    ADD CONSTRAINT `contact_contactlist_ibfk_6` 
      FOREIGN KEY (`contactlist_id`) REFERENCES `contactLists` (`id`) ON DELETE CASCADE;  
  ALTER TABLE `contactLists`
    ADD CONSTRAINT `contactlists_ibfk_1` 
      FOREIGN KEY (`owner_id`) REFERENCES `serviceAccounts` (`id`);
  </code></pre>
  
  <p>(phpMyAdmin export of the very same keys above)</p>
  
  <p>The problem manifests itself as MySQL won't let me insert anything  into the tables if the keys are defined with the SQL from the first block, complaining on referential integrity (even though the referenced entries exist), yet all is well if I set the keys with the SQL from the second block.</p>
  
  <p>I am aware that I can just "go on and be happy" using the latter key definition SQL, but I'd prefer if I could somehow just stick to the Doctrine-generated SQL as I'm still early in development and model will change quite often (thus the two-step manual key fixing will become rather annoying).</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Here are the create statements</p>
  
  <pre><code>CREATE TABLE contact_contactlist (
    contact_id BIGINT NOT NULL, 
    contactlist_id BIGINT NOT NULL, 
    INDEX contact_contactlist_contact_id_idx (contact_id), 
    INDEX contact_contactlist_contactlist_id_idx (contactlist_id), 
    PRIMARY KEY(contact_id, contactlist_id)) 
  ENGINE = InnoDB; 
  
  CREATE TABLE contactLists (
    id BIGINT AUTO_INCREMENT NOT NULL, 
    owner_id INT DEFAULT NULL, 
    name VARCHAR(255) NOT NULL, 
    INDEX contactLists_owner_id_idx (owner_id), 
    PRIMARY KEY(id)) 
  ENGINE = InnoDB;
  </code></pre>