-- Deploy gaia:doctor_2016_03_28_add_doctorActivity_and_ActivityParticipate_table to mysql

BEGIN;

CREATE TABLE `doctor_doctoractivity` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `title` varchar(100) NOT NULL DEFAULT "",
    `content_id` int(11) NOT NULL,
    `is_online` bool NOT NULL DEFAULT FALSE,
    `begin_time` DATETIME NOT NULL,
    `end_time` DATETIME NOT NULL,
    `created_time` DATETIME,
    `update_time` DATETIME,
    FOREIGN KEY (`content_id`) REFERENCES `doctor_content` (`id`),
    PRIMARY KEY (`id`)
);
ALTER TABLE `doctor_doctoractivity` ADD CONSTRAINT `content_id_refs_id_65979f9c` FOREIGN KEY (`content_id`) REFERENCES `doctor_content` (`id`);

CREATE TABLE `doctor_activityparticipate` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `doctor_id` varchar(100) NOT NULL,
    `activity_id` int(11) NOT NULL,
    `created_time` datetime NOT NULL,
    FOREIGN KEY (`activity_id`) REFERENCES `doctor_doctoractivity` (`id`),
    FOREIGN KEY (`doctor_id`) REFERENCES `api_doctor` (`id`),
    PRIMARY KEY (`id`)
);
ALTER TABLE `doctor_activityparticipate` ADD CONSTRAINT `activity_id_refs_id_98eeb31d` FOREIGN KEY (`activity_id`) REFERENCES `doctor_doctoractivity` (`id`);
ALTER TABLE `doctor_activityparticipate` ADD CONSTRAINT `doctor_id_refs_id_8a4fb741` FOREIGN KEY (`doctor_id`) REFERENCES `api_doctor` (`id`);

COMMIT;
