-- Deploy mimas-qa:qa_2017_10_10_alter_question to mysql

BEGIN;

ALTER TABLE `api_question` ADD COLUMN `is_invite_doctor` bool DEFAULT FALSE;

CREATE TABLE `api_question_doctor` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `question_id` integer NOT NULL,
    `doctor_id` varchar(100) NOT NULL,
    `unread` bool DEFAULT TRUE,
    `create_time` datetime(6) NOT NULL
);
ALTER TABLE `api_question_doctor` ADD CONSTRAINT `api_question_doctor_ibfk_1` FOREIGN KEY (`question_id`) REFERENCES `api_question` (`id`);
CREATE index doctor_index on  api_question_doctor(doctor_id);
CREATE index create_t_index on  api_question_doctor(create_time);

COMMIT;
