-- Deploy mimas-qa:api_2018_05_16_create_table_toutiaotag_and_toutiaorelation to mysql

BEGIN;

CREATE TABLE `api_toutiaotag` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `toutiao` varchar(40) NOT NULL UNIQUE,
    `is_online` bool NOT NULL,
    `is_related` bool NOT NULL,
    `count` integer DEFAULT 0,
    `create_time` datetime(6) NOT NULL
)
;
CREATE TABLE `api_toutiaorelation` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `toutiaotag_id` integer NOT NULL,
    `tag` varchar(40)
)
;
ALTER TABLE `api_toutiaorelation` ADD CONSTRAINT `toutiaotag_id_refs_id_f3c1aa31` FOREIGN KEY (`toutiaotag_id`) REFERENCES `api_toutiaotag` (`id`);
COMMIT;
