-- Deploy mimas-talos:api_2018_04_03_add_index_table to mysql

BEGIN;

CREATE TABLE `mixed_index` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `original_id` int(11) NOT NULL,
  `original_type` varchar(2) NOT NULL,
  `answer_content_level` varchar(2) DEFAULT NULL,
  `original_create_time` datetime(6) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `original_id_type_key` (original_id, original_type)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE `mixed_index_tag` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `mix_index_id` int(11) NOT NULL,
  `tag_id` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `mixed_index_tag_key` (`tag_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;

ALTER TABLE `mixed_index_tag` ADD CONSTRAINT `mix_index_refs_id_29c32152` FOREIGN KEY (`mix_index_id`) REFERENCES `mixed_index` (`id`);


COMMIT;
