title: can't add foreign key in mysql?
body: <p>I used MySQL workbench to add a foreign key in a table, but some strange error happened, this is the SQL statement:</p>
  
  <pre><code>ALTER TABLE `tansung`.`Declaration` ADD COLUMN `goodsId` INT(11) NOT NULL  AFTER `declarationId` , 
      ADD CONSTRAINT `goodsId`
          FOREIGN KEY (`goodsId` )
          REFERENCES `tansung`.`Goods` (`goodsId` )
          ON DELETE NO ACTION
          ON UPDATE NO ACTION
      , ADD INDEX `goodsId` (`goodsId` ASC) ;
  </code></pre>
  
  <p>When i click apply, the surprise comes out!</p>
  
  <pre><code>ERROR 1005: Can't create table 'tansung.#sql-1b10_1' (errno: 150)
  
  SQL Statement:
  
  ALTER TABLE `tansung`.`Declaration` ADD COLUMN `goodsId` INT(11) NOT NULL  AFTER `declarationId` , 
      ADD CONSTRAINT `goodsId`
          FOREIGN KEY (`goodsId` )
          REFERENCES `tansung`.`Goods` (`goodsId` )
          ON DELETE NO ACTION
          ON UPDATE NO ACTION
      , ADD INDEX `goodsId` (`goodsId` ASC)
  
  
  ERROR: Error when running failback script. Details follow.
  
  
  ERROR 1050: Table 'Declaration' already exists
  
  SQL Statement:
  
  CREATE TABLE `Declaration` (
      `declarationId` int(11) NOT NULL,
      PRIMARY KEY (`declarationId`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8
  </code></pre>
  
  <p>I can't find out any mistake in logic, even can't understand the error, please give me a help.</p>