-- Deploy mimas-qa:2018_01_05_create_api_kol to mysql

BEGIN;

-- XXX Add DDLs here.
CREATE TABLE `api_kolquestion` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `platform` varchar(2) NOT NULL,
    `original_id` integer,
    `create_time` datetime(6) NOT NULL,
    `update_time` datetime(6) NOT NULL,
    `title` varchar(128) NOT NULL,
    `author_name` varchar(128) NOT NULL,
    `author_headline` varchar(256) NOT NULL,
    `author_token` varchar(128) NOT NULL,
    `question_id` integer,
    `vast_id` integer,
    `review_time` datetime(6) NOT NULL,
    `catch_time` datetime(6) NOT NULL,
    UNIQUE KEY(platform, original_id)
)
;
CREATE TABLE `api_kolanswer` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `platform` varchar(2) NOT NULL,
    `original_id` integer NOT NULL,
    `create_time` datetime(6) NOT NULL,
    `update_time` datetime(6) NOT NULL,
    `content` longtext NOT NULL,
    `author_name` varchar(128) NOT NULL,
    `author_headline` varchar(256) NOT NULL,
    `author_token` varchar(128) NOT NULL,
    `kol_question_id` integer NOT NULL,
    `answer_id` integer,
    `question_id` integer,
    `vast_id` integer,
    `review_time` datetime(6) NOT NULL,
    `catch_time` datetime(6) NOT NULL,
    UNIQUE KEY(platform, original_id)
)
;

COMMIT;
