-- Deploy gaia:api_20190807_add_smartrank_time to mysql

BEGIN;

ALTER TABLE `api_smart_rank` ADD COLUMN `update_time` datetime(6);
CREATE TABLE `api_smart_rank_compare` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `service_id` integer NOT NULL,
    `check_time` datetime(6) NOT NULL,
    `mysql_smart_rank` double precision NOT NULL,
    `es_smart_rank` double precision NOT NULL,
    `mysql_new_smart_rank` double precision NOT NULL,
    `es_new_smart_rank` double precision NOT NULL,
    `sr_delta` double precision NOT NULL,
    `srn_delta` double precision NOT NULL
);
ALTER TABLE `api_smart_rank_compare` ADD INDEX `checktime_with_srndelta` (`check_time`, `srn_delta`);
ALTER TABLE `api_smart_rank_compare` ADD INDEX `service_id_index` (`service_id`);

COMMIT;
