-- Deploy gaia:api_2017_07_31_add_hospita_info to mysql

BEGIN;

CREATE TABLE `api_hospitalinfo` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `hospital_id` varchar(100) NOT NULL UNIQUE,
    `hospital_level` varchar(20) NOT NULL,
    `hospital_area` varchar(20) NOT NULL,
    `city_num` integer NOT NULL,
    `hospital_num` integer NOT NULL,
    `operation_num` integer NOT NULL,
    `injection_num` integer NOT NULL,
    `laser_num` integer NOT NULL,
    `major_doc` integer NOT NULL,
    `vice_doc` integer NOT NULL,
    `main_doc` integer NOT NULL,
    `in_doc` integer NOT NULL,
    `other_doc` integer NOT NULL,
    `reason` varchar(100),
    `status` integer NOT NULL,
    `created_time` datetime(6) NOT NULL,
    `submit_time` datetime(6) NOT NULL
);
ALTER TABLE `api_hospitalinfo` ADD CONSTRAINT `hospital_id_refs_id_ef106b3f` FOREIGN KEY (`hospital_id`) REFERENCES `api_hospital` (`id`);
CREATE TABLE `api_hospitallicenes` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `hospital_id` varchar(100) NOT NULL,
    `image_url` varchar(256) NOT NULL,
    `type` integer NOT NULL
);
ALTER TABLE `api_hospitallicenes` ADD CONSTRAINT `hospital_id_refs_id_1b6b8c62` FOREIGN KEY (`hospital_id`) REFERENCES `api_hospital` (`id`);
CREATE TABLE `api_hospitalinfolicenes` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `hospitalinfo_id` integer NOT NULL,
    `image_url` varchar(256) NOT NULL,
    `type` integer NOT NULL
);
ALTER TABLE `api_hospitalinfolicenes` ADD CONSTRAINT `hospitalinfo_id_refs_id_2bdc28b3` FOREIGN KEY (`hospitalinfo_id`) REFERENCES `api_hospitalinfo` (`id`);

COMMIT;
