-- Deploy gaia:statistic_2019_11_13_statistic_service_smart_rank_v4 to mysql

BEGIN;

-- XXX Add DDLs here.
CREATE TABLE `statistic_service_smart_rank_v4` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `service_id` integer NOT NULL,
    `stat_date` date NOT NULL,
    `service_detail_click_count_30` integer  NOT NULL,
    `service_detail_view_count_30` integer  NOT NULL,
    `merchant_income_30` double precision NOT NULL,
    `merchant_income_60` double precision NOT NULL,
    `merchant_income_90` double precision NOT NULL,
    `merchant_income_180` double precision NOT NULL,
    `merchant_discount_30` double precision NOT NULL,
    `merchant_discount_60` double precision NOT NULL,
    `merchant_discount_90` double precision NOT NULL,
    `merchant_discount_180` double precision NOT NULL,
    `merchant_ad_money_30` double precision NOT NULL,
    `merchant_ad_money_60` double precision NOT NULL,
    `merchant_ad_money_90` double precision NOT NULL,
    `merchant_ad_money_180` double precision NOT NULL,
    `merchant_ka_income_30` double precision NOT NULL,
    `merchant_ka_income_60` double precision NOT NULL,
    `merchant_ka_income_90` double precision NOT NULL,
    `merchant_ka_income_180` double precision NOT NULL,
    `merchant_validate_price_30` double precision NOT NULL,
    `merchant_validate_price_60` double precision NOT NULL,
    `merchant_validate_price_90` double precision NOT NULL,
    `merchant_validate_price_180` double precision NOT NULL,
    `merchant_service_detail_pv_30` integer  NOT NULL,
    `merchant_service_detail_pv_60` integer  NOT NULL,
    `merchant_service_detail_pv_90` integer  NOT NULL,
    `merchant_service_detail_pv_180` integer  NOT NULL,
    `consult_pv_30` integer  NOT NULL,
    `consult_pv_60` integer  NOT NULL,
    `consult_pv_90` integer  NOT NULL,
    `consult_pv_180` integer  NOT NULL,
    `service_detail_pv_30` integer  NOT NULL,
    `service_detail_pv_60` integer  NOT NULL,
    `service_detail_pv_90` integer  NOT NULL,
    `service_detail_pv_180` integer  NOT NULL
);


CREATE INDEX `statistic_service_smart_rank_v4_service_id_stat_date` ON `statistic_service_smart_rank_v4` (`service_id`,`stat_date`);

COMMIT;
