-- Deploy gaia:hippo_20171021_merchant to mysql

BEGIN;

CREATE TABLE `hippo_merchant` (
    `id` bigint NOT NULL PRIMARY KEY,
    `doctor_id` varchar(100) NOT NULL UNIQUE,
    `name` varchar(200) NOT NULL,
    `created_time` datetime(6) NOT NULL,
    `is_online` bool NOT NULL
)
;
ALTER TABLE `hippo_merchant` ADD CONSTRAINT `doctor_id_refs_id_5ca6b3b7` FOREIGN KEY (`doctor_id`) REFERENCES `api_doctor` (`id`);
CREATE TABLE `hippo_merchantrelevance` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `merchant_id` bigint NOT NULL,
    `doctor_id` varchar(100) NOT NULL UNIQUE
)
;
ALTER TABLE `hippo_merchantrelevance` ADD CONSTRAINT `merchant_id_refs_id_e34700a9` FOREIGN KEY (`merchant_id`) REFERENCES `hippo_merchant` (`id`);
ALTER TABLE `hippo_merchantrelevance` ADD CONSTRAINT `doctor_id_refs_id_56d037c9` FOREIGN KEY (`doctor_id`) REFERENCES `api_doctor` (`id`);
CREATE INDEX `hippo_merchantrelevance_4206e65a` ON `hippo_merchantrelevance` (`merchant_id`);

COMMIT;
