-- Deploy gaia:hippo_2018_04_17_add_doctor_business_data to mysql

BEGIN;

-- XXX Add DDLs here.
CREATE TABLE `hippo_business_data` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `merchant_id` bigint NOT NULL,
    `doctor_id` varchar(100) NOT NULL,
    `new_diary` integer NOT NULL,
    `five_stars_diary` integer NOT NULL,
    `four_stars_diary` integer NOT NULL,
    `advertise` integer NOT NULL,
    `diary_pv` integer NOT NULL,
    `service_pv` integer NOT NULL,
    `hospital_doctor_pv` integer NOT NULL,
    `phone` integer NOT NULL,
    `message` integer NOT NULL,
    `connect_phone` integer NOT NULL,
    `effective_message` integer NOT NULL,
    `to_the_hospital` integer NOT NULL,
    `consumption_people` integer NOT NULL,
    `consumption_cost` integer NOT NULL,
    `update_time` datetime(6) NOT NULL,
    `time_type` integer NOT NULL,
    `diary_rank` integer NOT NULL
)
;
ALTER TABLE `hippo_business_data` ADD CONSTRAINT `doctor_id_refs_id_cb9387f8` FOREIGN KEY (`doctor_id`) REFERENCES `api_doctor` (`id`);
ALTER TABLE `hippo_business_data` ADD CONSTRAINT `merchant_id_refs_id_dd0e538e` FOREIGN KEY (`merchant_id`) REFERENCES `hippo_merchant` (`id`);
CREATE TABLE `hippo_to_hospital` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `tohospital_time` date NOT NULL,
    `doctor_id` varchar(100) NOT NULL,
    `merchant_id` bigint NOT NULL,
    `created_time` datetime(6) NOT NULL,
    `update_time` datetime(6) NOT NULL,
    `num` integer NOT NULL
)
;
ALTER TABLE `hippo_to_hospital` ADD CONSTRAINT `doctor_id_refs_id_e0a5f017` FOREIGN KEY (`doctor_id`) REFERENCES `api_doctor` (`id`);
ALTER TABLE `hippo_to_hospital` ADD CONSTRAINT `merchant_id_refs_id_e5c99f52` FOREIGN KEY (`merchant_id`) REFERENCES `hippo_merchant` (`id`);


COMMIT;
