-- Deploy mimas-qa:qa_2018_01_25_create_table_api_question_inviter to mysql

BEGIN;

-- XXX Add DDLs here.
CREATE TABLE `api_question_inviter` (
  `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
  `user_id` int(11) NOT NULL,
  `inviter_id` int(11) NOT NULL,
  `answer_id` int(11) DEFAULT NULL,
  `question_id` int(11) DEFAULT NULL,
  `invite_time` datetime(6) NOT NULL,
  `user_read` bool NOT NULL DEFAULT FALSE,
  CONSTRAINT `fk_inviter_question_id` FOREIGN KEY (`question_id`) REFERENCES `api_question` (`id`),
  CONSTRAINT `fk_inviter_answer_id` FOREIGN KEY (`answer_id`) REFERENCES `api_answer` (`id`)
);
CREATE INDEX `idx_user_id` ON `api_question_inviter` (`user_id`);
CREATE INDEX `idx_inviter_id` ON `api_question_inviter` (`inviter_id`);
CREATE INDEX `idx_invite_time` ON `api_question_inviter` (`invite_time`);
COMMIT;
