-- Deploy gaia:api_2017_10_18_add_merchant to mysql

BEGIN;

CREATE TABLE `api_merchant` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `doctor_id` varchar(100) NOT NULL UNIQUE,
    `doctor_name` varchar(200) NOT NULL,
    `created_time` datetime(6) NOT NULL,
    `is_online` bool NOT NULL
);
ALTER TABLE `api_merchant` ADD CONSTRAINT `doctor_id_refs_id_9a31b012` FOREIGN KEY (`doctor_id`) REFERENCES `api_doctor` (`id`);
CREATE TABLE `api_merchantrelevance` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `merchant_id` integer NOT NULL,
    `doctor_id` varchar(100) NOT NULL
);
ALTER TABLE `api_merchantrelevance` ADD CONSTRAINT `doctor_id_refs_id_32ed1d47` FOREIGN KEY (`doctor_id`) REFERENCES `api_doctor` (`id`);
ALTER TABLE `api_merchantrelevance` ADD CONSTRAINT `merchant_id_refs_id_c63bde26` FOREIGN KEY (`merchant_id`) REFERENCES `api_merchant` (`id`);

COMMIT;
