-- 参数配置-系统设置属性

DELETE FROM
    `omc_db`.`sys_config`
WHERE
    `config_id` = 100
    and `config_key` = 'test';
DELETE FROM
    `omc_db`.`sys_config`
WHERE
    `config_id` != 102
    and `config_key` = 'sys.logo.type';
DELETE FROM
    `omc_db`.`sys_config`
WHERE
    `config_id` != 103
    and `config_key` = 'sys.logo.filePathIcon';
DELETE FROM
    `omc_db`.`sys_config`
WHERE
    `config_id` != 104
    and `config_key` = 'sys.title';
DELETE FROM
    `omc_db`.`sys_config`
WHERE
    `config_id` != 105
    and `config_key` = 'sys.copyright';
DELETE FROM
    `omc_db`.`sys_config`
WHERE
    `config_id` != 106
    and `config_key` = 'sys.logo.filePathBrand';
DELETE FROM
    `omc_db`.`sys_config`
WHERE
    `config_id` != 107
    and `config_key` = 'sys.loginBackground';               


-- 创建表 监控_基本信息

ALTER TABLE `omc_db`.`monitor_base` DROP COLUMN IF EXISTS `created_at`;
ALTER TABLE
    `omc_db`.`monitor_base` DROP COLUMN IF EXISTS `updated_at`;
ALTER TABLE `omc_db`.`monitor_base` DROP COLUMN IF EXISTS `db_size`;
ALTER TABLE
    `omc_db`.`monitor_base` MODIFY COLUMN `id` bigint(20) NOT NULL COMMENT 'id' FIRST;
ALTER TABLE
    `omc_db`.`monitor_base`
ADD
    COLUMN IF NOT EXISTS `create_time` bigint(20) NULL DEFAULT 0 COMMENT '创建时间' AFTER `id`;
ALTER TABLE
    `omc_db`.`monitor_base` MODIFY COLUMN `cpu` float NULL DEFAULT 0 COMMENT 'cpu使用率' AFTER `create_time`;
ALTER TABLE
    `omc_db`.`monitor_base` MODIFY COLUMN `load_usage` float NULL DEFAULT 0 COMMENT 'cpu平均使用率' AFTER `cpu`;
ALTER TABLE
    `omc_db`.`monitor_base` MODIFY COLUMN `cpu_load1` float NULL DEFAULT 0 COMMENT 'cpu使用1分钟' AFTER `load_usage`;
ALTER TABLE
    `omc_db`.`monitor_base` MODIFY COLUMN `cpu_load5` float NULL DEFAULT 0 COMMENT 'cpu使用5分钟' AFTER `cpu_load1`;
ALTER TABLE
    `omc_db`.`monitor_base` MODIFY COLUMN `cpu_load15` float NULL DEFAULT 0 COMMENT 'cpu使用15分钟' AFTER `cpu_load5`;
ALTER TABLE
    `omc_db`.`monitor_base` MODIFY COLUMN `memory` float NULL DEFAULT 0 COMMENT '内存使用率' AFTER `cpu_load15`;
ALTER TABLE
    `omc_db`.`monitor_base`
ADD
    COLUMN IF NOT EXISTS `ne_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '网元类型' AFTER `memory`;
ALTER TABLE
    `omc_db`.`monitor_base`
ADD
    COLUMN IF NOT EXISTS `ne_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '网元ID' AFTER `ne_type`;
ALTER TABLE
    `omc_db`.`monitor_base` MODIFY COLUMN `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id';

-- 创建表 监控_磁盘IO

ALTER TABLE `omc_db`.`monitor_io` DROP COLUMN IF EXISTS `created_at`;
ALTER TABLE `omc_db`.`monitor_io` DROP COLUMN IF EXISTS `updated_at`;
ALTER TABLE
    `omc_db`.`monitor_io` MODIFY COLUMN `id` bigint(20) NOT NULL COMMENT 'id' FIRST;
ALTER TABLE
    `omc_db`.`monitor_io`
ADD
    COLUMN IF NOT EXISTS `create_time` bigint(20) NULL DEFAULT 0 COMMENT '创建时间' AFTER `id`;
ALTER TABLE
    `omc_db`.`monitor_io` MODIFY COLUMN `name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '磁盘名' AFTER `create_time`;
ALTER TABLE
    `omc_db`.`monitor_io` MODIFY COLUMN `read` int(11) NULL DEFAULT 0 COMMENT '读取K' AFTER `name`;
ALTER TABLE
    `omc_db`.`monitor_io` MODIFY COLUMN `write` int(11) NULL DEFAULT 0 COMMENT '写入K' AFTER `read`;
ALTER TABLE
    `omc_db`.`monitor_io` MODIFY COLUMN `count` int(11) NULL DEFAULT 0 COMMENT '次数' AFTER `write`;
ALTER TABLE
    `omc_db`.`monitor_io` MODIFY COLUMN `time` int(11) NULL DEFAULT 0 COMMENT '耗时' AFTER `count`;
ALTER TABLE
    `omc_db`.`monitor_io`
ADD
    COLUMN IF NOT EXISTS `ne_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '网元类型' AFTER `time`;
ALTER TABLE
    `omc_db`.`monitor_io`
ADD
    COLUMN IF NOT EXISTS `ne_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '网元ID' AFTER `ne_type`;
ALTER TABLE
    `omc_db`.`monitor_io` MODIFY COLUMN `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id';

-- 创建表 监控_网络IO

ALTER TABLE `omc_db`.`monitor_network` DROP COLUMN IF EXISTS `created_at`;
ALTER TABLE `omc_db`.`monitor_network` DROP COLUMN IF EXISTS `updated_at`;
ALTER TABLE
    `omc_db`.`monitor_network` MODIFY COLUMN `id` bigint(20) NOT NULL COMMENT 'id' FIRST;
ALTER TABLE
    `omc_db`.`monitor_network`
ADD
    COLUMN IF NOT EXISTS `create_time` bigint(20) NULL DEFAULT 0 COMMENT '创建时间' AFTER `id`;
ALTER TABLE
    `omc_db`.`monitor_network` MODIFY COLUMN `name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '网卡名' AFTER `create_time`;
ALTER TABLE
    `omc_db`.`monitor_network` MODIFY COLUMN `up` float NULL DEFAULT 0 COMMENT '上行' AFTER `name`;
ALTER TABLE
    `omc_db`.`monitor_network` MODIFY COLUMN `down` float NULL DEFAULT 0 COMMENT '下行' AFTER `up`;
ALTER TABLE
    `omc_db`.`monitor_network`
ADD
    COLUMN IF NOT EXISTS `ne_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '网元类型' AFTER `down`;
ALTER TABLE
    `omc_db`.`monitor_network`
ADD
    COLUMN IF NOT EXISTS `ne_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '网元ID' AFTER `ne_type`;
ALTER TABLE
    `omc_db`.`monitor_network` MODIFY COLUMN `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id';

-- 参数配置-监控-系统资源
INSERT IGNORE INTO `omc_db`.`sys_config` (`config_id`, `config_name`, `config_key`, `config_value`, `config_type`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (10, '监控-系统资源-数据保留时长', 'monitor.sysResource.storeDays', '30', 'Y', 'admin', 1698483370391, '', 0, '监控-系统资源-数据保留时长，单位天。根据当前日期，删除超过保留时长的日期数据信息。');

-- sys_job
INSERT IGNORE INTO
    `omc_db`.`sys_job` (
        `job_id`,
        `job_name`,
        `job_group`,
        `invoke_target`,
        `target_params`,
        `cron_expression`,
        `misfire_policy`,
        `concurrent`,
        `status`,
        `save_log`,
        `create_by`,
        `create_time`,
        `update_by`,
        `update_time`,
        `remark`
    )
VALUES (
        1,
        '监控-系统资源',
        'SYSTEM',
        'monitor_sys_resource',
        '{\"interval\":5}',
        '0 0/5 * * * ?',
        '3',
        '0',
        '1',
        '0',
        'admin',
        1698478134839,
        'admin',
        1698483081920,
        '系统资源CPU/IO/Netword收集，interval单位分钟，0 0/5 * * * ? 表示平均interva5分钟资源情况'
    );