title: SQL Error 1022: Can't write; duplicate key in table
body: <p>I've read all the similar errors here, still can't figure out why am I getting this error</p>
  
  <pre><code>Executing SQL script in server
  ERROR: Error 1022: Can't write; duplicate key in table 'storage'
  SQL Code:
      -- -----------------------------------------------------
      -- Table `storehouse`.`storage`
      -- -----------------------------------------------------
      CREATE TABLE IF NOT EXISTS `storehouse`.`storage` (
        `product_id` INT NOT NULL,
        `quantity` INT NULL,
        `storage_room` INT NULL,
        UNIQUE INDEX `product_id_UNIQUE` (`product_id` ASC),
        INDEX `storage_room_idx` (`storage_room` ASC),
        CONSTRAINT `product_id`
          FOREIGN KEY (`product_id`)
          REFERENCES `storehouse`.`product` (`product_id`)
          ON DELETE NO ACTION
          ON UPDATE NO ACTION,
        CONSTRAINT `storage_room`
          FOREIGN KEY (`storage_room`)
          REFERENCES `storehouse`.`space` (`space_id`)
          ON DELETE NO ACTION
          ON UPDATE NO ACTION)
      ENGINE = InnoDB
  </code></pre>
  
  <p>I've checked: all the keys are unique</p>