title: Workbench and InnoDB error 150 varchar FK
body: <p>I am working on a database in Workbench but I am stuck on a problem with the foreign key between <code>post</code> and <code>language</code>. I am assuming that that <code>fk</code> triggers this error because when I remove this <code>fk</code> the query runs without any problems. I have checked the <code>type</code> compatibility and made sure the indexes are present. I am missing something here?</p>
  
  <p>The goal of this <code>fk</code> is to reference those both tables on <code>varchar</code>.</p>
  
  <p>SQL that triggers the 150 (InnoDB):</p>
  
  <pre><code>-- MySQL Script generated by MySQL Workbench
  -- 04/05/14 22:08:25
  -- Model: New Model    Version: 1.0
  SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
  SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
  SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
  
  -- -----------------------------------------------------
  -- Schema SBDB_v0.1.2
  -- -----------------------------------------------------
  CREATE SCHEMA IF NOT EXISTS `SBDB_v0.1.2` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ;
  USE `SBDB_v0.1.2` ;
  
  -- -----------------------------------------------------
  -- Table `SBDB_v0.1.2`.`language`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `SBDB_v0.1.2`.`language` (
    `id` INT NOT NULL,
    `language` VARCHAR(120) NOT NULL,
    `lang_abr` CHAR(3) NULL,
    PRIMARY KEY (`id`, `language`))
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `SBDB_v0.1.2`.`post`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `SBDB_v0.1.2`.`post` (
    `id` INT NOT NULL AUTO_INCREMENT,
    `language` VARCHAR(120) NOT NULL,
    `thumbnail_name` VARCHAR(255) NOT NULL,
    `id_sk` INT NULL,
    `title` VARCHAR(255) NULL,
    `author` VARCHAR(45) NULL,
    `message` TEXT NULL,
    `date_created` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
    `last_time_modified` TIMESTAMP NULL,
    PRIMARY KEY (`id`),
    INDEX `language_1_idx` (`language` ASC),
    CONSTRAINT `language_1`
      FOREIGN KEY (`language`)
      REFERENCES `SBDB_v0.1.2`.`language` (`language`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION)
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `SBDB_v0.1.2`.`image`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `SBDB_v0.1.2`.`image` (
    `id` INT NOT NULL AUTO_INCREMENT,
    `language` VARCHAR(255) NOT NULL,
    `name` VARCHAR(255) NOT NULL,
    `upload_date` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (`id`, `language`),
    INDEX `name_1_idx` (`name` ASC))
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `SBDB_v0.1.2`.`category`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `SBDB_v0.1.2`.`category` (
    `id` INT NOT NULL AUTO_INCREMENT,
    `language` VARCHAR(255) NOT NULL,
    `title` VARCHAR(255) NULL,
    `description` VARCHAR(255) NULL,
    `date_created` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (`id`, `language`))
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `SBDB_v0.1.2`.`post_category`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `SBDB_v0.1.2`.`post_category` (
    `id_post` INT NOT NULL,
    `id_category` INT NOT NULL,
    PRIMARY KEY (`id_post`, `id_category`),
    INDEX `id_category_idx` (`id_category` ASC),
    CONSTRAINT `id_post`
      FOREIGN KEY (`id_post`)
      REFERENCES `SBDB_v0.1.2`.`post` (`id`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION,
    CONSTRAINT `id_category`
      FOREIGN KEY (`id_category`)
      REFERENCES `SBDB_v0.1.2`.`category` (`id`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION)
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `SBDB_v0.1.2`.`page`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `SBDB_v0.1.2`.`page` (
    `id` INT NOT NULL AUTO_INCREMENT,
    `id_page_pass` INT NULL,
    `title` VARCHAR(255) NULL,
    `content` MEDIUMTEXT NULL,
    `date_created` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
    `last_time_modified` TIMESTAMP NULL,
    PRIMARY KEY (`id`, `id_page_pass`))
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `SBDB_v0.1.2`.`page_password`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `SBDB_v0.1.2`.`page_password` (
    `id` INT NOT NULL AUTO_INCREMENT,
    `password` VARCHAR(255) NOT NULL,
    `date_created` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (`id`),
    CONSTRAINT `id_page211`
      FOREIGN KEY (`id`)
      REFERENCES `SBDB_v0.1.2`.`page` (`id`)
      ON DELETE CASCADE
      ON UPDATE CASCADE)
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `SBDB_v0.1.2`.`search_keyword`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `SBDB_v0.1.2`.`search_keyword` (
    `id` INT NOT NULL AUTO_INCREMENT,
    `language` VARCHAR(255) NOT NULL,
    `keyword` VARCHAR(255) NULL,
    PRIMARY KEY (`id`, `language`))
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `SBDB_v0.1.2`.`post_search_keyword`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `SBDB_v0.1.2`.`post_search_keyword` (
    `id_post` INT NOT NULL,
    `id_sk` INT NOT NULL,
    PRIMARY KEY (`id_post`, `id_sk`),
    INDEX `id_sk_1_idx` (`id_sk` ASC),
    CONSTRAINT `id_post_2`
      FOREIGN KEY (`id_post`)
      REFERENCES `SBDB_v0.1.2`.`post` (`id`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION,
    CONSTRAINT `id_sk_1`
      FOREIGN KEY (`id_sk`)
      REFERENCES `SBDB_v0.1.2`.`search_keyword` (`id`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION)
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `SBDB_v0.1.2`.`user`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `SBDB_v0.1.2`.`user` (
    `id` INT NOT NULL AUTO_INCREMENT,
    `login` VARCHAR(25) NOT NULL,
    `password` VARCHAR(255) NOT NULL,
    `firstname` VARCHAR(45) NULL,
    `lastname` VARCHAR(45) NULL,
    PRIMARY KEY (`id`))
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `SBDB_v0.1.2`.`social_media`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `SBDB_v0.1.2`.`social_media` (
    `id` INT NOT NULL AUTO_INCREMENT,
    `language` VARCHAR(255) NOT NULL,
    `name` VARCHAR(45) NULL,
    `link` VARCHAR(255) NULL,
    PRIMARY KEY (`id`))
  ENGINE = InnoDB;
  
  
  SET SQL_MODE=@OLD_SQL_MODE;
  SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
  SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
  </code></pre>