-- Deploy gaia:api_20160920_create_table_shortmessagesend to mysql

BEGIN;

-- XXX Add DDLs here.
CREATE TABLE `api_shortmessagesend` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `content` varchar(75) NOT NULL,
    `order_status` varchar(100),
    `send_time` datetime(6) NOT NULL,
    `send_status` bool NOT NULL,
    `phone_list` longtext NOT NULL
)
;
CREATE TABLE `api_shortmessagesendservice` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `service_id` integer NOT NULL,
    `shortmessagesend_id` integer NOT NULL
)
;
ALTER TABLE `api_shortmessagesendservice` ADD CONSTRAINT `service_id_refs_id_74b409ee` FOREIGN KEY (`service_id`) REFERENCES `api_service` (`id`);
ALTER TABLE `api_shortmessagesendservice` ADD CONSTRAINT `shortmessagesend_id_refs_id_0c77dc24` FOREIGN KEY (`shortmessagesend_id`) REFERENCES `api_shortmessagesend` (`id`);
CREATE TABLE `api_shortmessagesenddoctor` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `doctor_id` varchar(100) NOT NULL,
    `shortmessagesend_id` integer NOT NULL
)
;
ALTER TABLE `api_shortmessagesenddoctor` ADD CONSTRAINT `shortmessagesend_id_refs_id_49a23d22` FOREIGN KEY (`shortmessagesend_id`) REFERENCES `api_shortmessagesend` (`id`);
ALTER TABLE `api_shortmessagesenddoctor` ADD CONSTRAINT `doctor_id_refs_id_ae0c566a` FOREIGN KEY (`doctor_id`) REFERENCES `api_doctor` (`id`);
CREATE TABLE `api_shortmessagesendhospital` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `hospital_id` varchar(100) NOT NULL,
    `shortmessagesend_id` integer NOT NULL
)
;
ALTER TABLE `api_shortmessagesendhospital` ADD CONSTRAINT `hospital_id_refs_id_7b30f65e` FOREIGN KEY (`hospital_id`) REFERENCES `api_hospital` (`id`);
ALTER TABLE `api_shortmessagesendhospital` ADD CONSTRAINT `shortmessagesend_id_refs_id_dd0e8db3` FOREIGN KEY (`shortmessagesend_id`) REFERENCES `api_shortmessagesend` (`id`);


COMMIT;
