CREATE TABLE IF NOT EXISTS robo_assets_pool
(
    rap_id          BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
    rap_date        DATETIME        NOT NULL COMMENT '数据日期',
    rap_type        TINYINT         NOT NULL COMMENT '资产池类别',
    rap_asset_ids   JSON                     DEFAULT NULL COMMENT '基金ID',
    rap_create_time DATETIME        NOT NULL DEFAULT CURRENT_TIMESTAMP,
    rap_update_time DATETIME                 DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
    PRIMARY KEY (rap_id),
    UNIQUE INDEX (rap_date, rap_type),
    INDEX (rap_type)
) ENGINE = InnoDB
  AUTO_INCREMENT = 0
  DEFAULT CHARSET = utf8mb4 COMMENT '资产池';


CREATE TABLE IF NOT EXISTS asset_risk_dates
(
    ard_id          BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
    ard_date        DATETIME        NOT NULL COMMENT '风控日期',
    ard_type        TINYINT         NOT NULL COMMENT '日期类型',
    ard_asset_id    BIGINT UNSIGNED NOT NULL COMMENT '资产ID',
    ard_create_time DATETIME        NOT NULL DEFAULT CURRENT_TIMESTAMP,
    ard_update_time DATETIME                 DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
    PRIMARY KEY (ard_id),
    INDEX (ard_date),
    INDEX (ard_type),
    INDEX (ard_asset_id)
) ENGINE = InnoDB
  AUTO_INCREMENT = 0
  DEFAULT CHARSET = utf8mb4 COMMENT '资产风控日期表';


CREATE TABLE IF NOT EXISTS asset_ewma_value
(
    aev_id          BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
    aev_date        DATETIME        NOT NULL COMMENT '日期',
    aev_asset_id    BIGINT UNSIGNED NOT NULL COMMENT '资产ID',
    aev_value   DOUBLE NOT NULL COMMENT 'ewma值',
    aev_create_time DATETIME        NOT NULL DEFAULT CURRENT_TIMESTAMP,
    aev_update_time DATETIME                 DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
    PRIMARY KEY (aev_id),
    UNIQUE INDEX (aev_asset_id, aev_date),
    INDEX (aev_date)
) ENGINE = InnoDB
  AUTO_INCREMENT = 0
  DEFAULT CHARSET = utf8mb4 COMMENT '资产EWMA数据';