-- Deploy gaia:api_2017_05_16_add_aq_of_zone to mysql

BEGIN;

ALTER TABLE `api_zone` ADD COLUMN `show_qa_tab` bool DEFAULT FALSE;
ALTER TABLE `api_zone` ADD COLUMN `qa_tab_position` integer DEFAULT 3;
CREATE TABLE `api_overheadanswer` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `zone_id` integer NOT NULL,
    `answer_id` integer NOT NULL,
    `rank` integer NOT NULL,
    `created_time` datetime(6) NOT NULL,
    `deleted` bool NOT NULL
);
CREATE TABLE `api_overheadquestion` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `zone_id` integer NOT NULL,
    `question_id` integer NOT NULL,
    `rank` integer NOT NULL,
    `created_time` datetime(6) NOT NULL,
    `deleted` bool NOT NULL
);
ALTER TABLE `api_overheadquestion` ADD CONSTRAINT `zone_id_refs_id_1fde06e9` FOREIGN KEY (`zone_id`) REFERENCES `api_zone` (`id`);
ALTER TABLE `api_overheadquestion` ADD CONSTRAINT `question_id_refs_id_201f6bf8` FOREIGN KEY (`question_id`) REFERENCES `api_question` (`id`);
ALTER TABLE `api_overheadanswer` ADD CONSTRAINT `zone_id_refs_id_c154f0c5` FOREIGN KEY (`zone_id`) REFERENCES `api_zone` (`id`);
ALTER TABLE `api_overheadanswer` ADD CONSTRAINT `answer_id_refs_id_89b6f028` FOREIGN KEY (`answer_id`) REFERENCES `api_answer` (`id`);

COMMIT;
