-- Deploy gaia:api_2017_11_17_record_doctor_coupon_info to mysql

BEGIN;

CREATE TABLE `api_doctorcouponinforecord` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `doctor_id` varchar(100) NOT NULL,
    `coupon_data_batch` varchar(20) NOT NULL,
    `coupon_id` integer NOT NULL,
    `threshold` integer NOT NULL,
    `value` integer NOT NULL,
    `left_number` integer NOT NULL,
    `created_time` datetime(6) NOT NULL,
    KEY `api_doctorcouponinforecord_470a4479` (`doctor_id`,`coupon_data_batch`)
);

CREATE VIEW `api_doctor_id_to_sku_id_view` AS (
SELECT spu.doctor_id AS doctor_id, sku.id AS sku_id
FROM api_serviceitem sku
JOIN api_service spu ON sku.service_id = spu.id);

COMMIT;
