-- Deploy gaia:api_20171221_use_two_coupon to mysql

BEGIN;

ALTER TABLE `api_settlement` ADD COLUMN `coupon_info_ids_data` varchar(1024) NOT NULL;

ALTER TABLE `api_coupon` ADD COLUMN `threshold_validation_type` integer NOT NULL;

CREATE TABLE `api_ordercouponinfo` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `order_id` varchar(30) NOT NULL,
    `coupon_id` integer NOT NULL,
    `coupon_info_id` integer NOT NULL,
    `coupon_name` varchar(15) NOT NULL,
    `coupon_value` integer NOT NULL,
    `coupon_type` integer NOT NULL,
    `platform_coupon_deduction` integer NOT NULL,
    `coupon_gengmei_percent` integer NOT NULL,
    `coupon_gengmei_value` integer NOT NULL,
    `coupon_doctor_value` integer NOT NULL,
    `doctor_coupon_deduction` integer NOT NULL,

    KEY `idx_api_ordercouponinfo_order_id` (`order_id`),
    KEY `idx_api_ordercouponinfo_coupon_id` (`coupon_id`),
    KEY `idx_api_ordercouponinfo_coupon_info_id` (`coupon_info_id`),
    KEY `idx_api_ordercouponinfo_coupon_type` (`coupon_type`)
);


COMMIT;
