-- -----------------------------------------------------
-- Table attributeCodeT
-- -----------------------------------------------------

-- DROP TABLE IF EXISTS attributeCodeT ;

CREATE TABLE IF NOT EXISTS attributeCodeT (
  id INT UNSIGNED NOT NULL,
  attributeCode VARCHAR(30) BINARY NOT NULL,
  PRIMARY KEY (id),
  UNIQUE INDEX attributeCode_UNIQUE (attributeCode ASC),
  CONSTRAINT fk_attributeCodeT_attributeT1
    FOREIGN KEY (id)
    REFERENCES attributeT (id)
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB;


-- fill in the attributeCodeT

insert attributeCodeT(id, attributeCode)
select id, code
from attributeT
where code is not null;


-- drop the code column

alter table attributeT drop code;

