-- Deploy gaia:2017_07_13_alter_table_smart_rank_add_column to mysql

BEGIN;

-- XXX Add DDLs here.
Alter TABLE api_smart_rank ADD  COLUMN new_smart_rank FLOAT DEFAULT 0;

CREATE TABLE `statistic_service_smart_rank` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `service_id` integer NOT NULL,
    `stat_date` date NOT NULL,
    `consult_value` double precision NOT NULL,
    `doctor_rate` double precision NOT NULL,
    `service_rate` double precision NOT NULL,
    `diary_rate` double precision NOT NULL,
    `order_value` double precision NOT NULL,
    `discount_value` double precision NOT NULL,
    `refund_value` double precision NOT NULL,
    `ad_money` double precision NOT NULL,
    `high_quality_diary_count` integer NOT NULL
)
;
ALTER TABLE `statistic_service_smart_rank` ADD CONSTRAINT `service_id_refs_id_6a837db9` FOREIGN KEY (`service_id`) REFERENCES `api_service` (`id`);

CREATE TABLE `api_manual_index` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `service_id` integer UNIQUE,
    `index` integer NOT NULL
)
;

COMMIT;

