-- Deploy gaia:create_table_api_feedbackmessage to mysql
-- 反馈追加消息表

BEGIN;

CREATE TABLE `api_feedbackmessage` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `person_id` char(32) DEFAULT NULL,
  `servant_id` char(32) DEFAULT NULL,
  `feedback_id` int(11) NOT NULL,
  `message` TEXT NOT NULL,
  `message_type` varchar(1) NOT NULL,
  `created_time` DATETIME NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

ALTER TABLE `api_feedbackmessage` ADD CONSTRAINT `fk_api_feedbackmessage_person_id_ref_api_person` FOREIGN KEY (`person_id`) REFERENCES `api_person` (`id`) ON DELETE CASCADE;
ALTER TABLE `api_feedbackmessage` ADD CONSTRAINT `fk_api_feedbackmessage_servant_id_ref_api_person` FOREIGN KEY (`servant_id`) REFERENCES `api_person` (`id`) ON DELETE CASCADE;
ALTER TABLE `api_feedbackmessage` ADD CONSTRAINT `fk_api_feedbackmessage_feedback_id_ref_api_feedback` FOREIGN KEY (`feedback_id`) REFERENCES `api_feedback` (`id`) ON DELETE CASCADE;

COMMIT;
