-- Deploy gaia:launch_2020_03_24_add_table to mysql

BEGIN;

-- XXX Add DDLs here.
ALTER TABLE `api_questionnaire_theme_and_question_relations` ADD COLUMN `sub_questions_show_nums` integer NULL DEFAULT 0;

CREATE TABLE `api_questionnaire_answer_relation_tag_v3` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `questionnaire_answer_id` integer NOT NULL,
    `tag_v3_id` integer NOT NULL,
    `create_time` datetime(6) NOT NULL,
    `update_time` datetime(6) NOT NULL
);
ALTER TABLE `api_questionnaire_answer_relation_tag_v3` ADD CONSTRAINT `questionnaire_answer_id_refs_id_ad4ae6d6` FOREIGN KEY (`questionnaire_answer_id`) REFERENCES `api_questionnaire_answer` (`id`);

CREATE TABLE `api_questionnaire_answer_interest_question` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `questionnaire_answer_id` integer NOT NULL,
    `question_id` integer NOT NULL
);

CREATE INDEX `api_questionnaire_answer_relation_tag_v3_8e5148db` ON `api_questionnaire_answer_relation_tag_v3` (`questionnaire_answer_id`);
CREATE INDEX `api_questionnaire_answer_relation_tag_v3_eb20a4b7` ON `api_questionnaire_answer_relation_tag_v3` (`tag_v3_id`);
CREATE INDEX `api_questionnaire_answer_interest_question_52f3e0fd` ON `api_questionnaire_answer_interest_question` (`questionnaire_answer_id`);
CREATE INDEX `api_questionnaire_answer_interest_question_19f7f452` ON `api_questionnaire_answer_interest_question` (`question_id`);

COMMIT;
