title: MySQL "Incorrect index name..." error (unique foreign key)
body: <p>I keep getting an error "Incorrect index name 'f7'" using MySQL and I've narrowed it down to the following:</p>
  
  <p>First I create the table,</p>
  
  <pre><code>CREATE TABLE testTable (
      id INTEGER PRIMARY KEY AUTO_INCREMENT,
      f7 INTEGER NOT NULL,
      FOREIGN KEY (f7) REFERENCES testTable2 (id) ON DELETE CASCADE ON UPDATE CASCADE,
  ) ENGINE=InnoDB;
  </code></pre>
  
  <p>And then elsewhere,</p>
  
  <pre><code>ALTER TABLE testTable ADD UNIQUE f7;
  </code></pre>
  
  <p><a href="https://stackoverflow.com/questions/5312083/mysql-unique-foreign-key">This</a> has led me to believe that this has to do with a duplicate index (?) I just can't figure out how to fix it. Many thanks.</p>