SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

--
-- Table structure for table `ne_state`
--
CREATE TABLE IF NOT EXISTS `ne_state` (
  `id` int NOT NULL AUTO_INCREMENT,
  `ne_type` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '',
  `ne_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '',
  `version` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '版本',
  `capability` bigint DEFAULT '0' COMMENT '用户容量',
  `serial_num` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '序列号',
  `expiry_date` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '许可证到期日期',
  `sys_cpu_usage` float DEFAULT '0' COMMENT 'cpu使用率-sys',
  `sys_mem_usage` float DEFAULT '0' COMMENT '内存使用率-sys',
  `sys_disk_usage` float DEFAULT '0' COMMENT '磁盘使用率-sys',
  `nf_cpu_usage` float DEFAULT '0' COMMENT 'cpu使用率-nf',
  `nf_mem_used` bigint DEFAULT '0' COMMENT '内存使用KB-nf',
  `create_time` bigint DEFAULT '0' COMMENT '创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `idx_type_id_time` (`ne_type`,`ne_id`,`create_time`) USING BTREE COMMENT 'idx_state_ne_type_id_at'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='网元_状态记录内存/CPU/磁盘';

-- ----------------------------
-- COLUMN for ne_state
-- ----------------------------
ALTER TABLE `ne_state` DROP COLUMN `cpu_usage`;
ALTER TABLE `ne_state` DROP COLUMN `mem_usage`;
ALTER TABLE `ne_state` DROP COLUMN `disk_space`;
ALTER TABLE `ne_state` DROP COLUMN `timestamp`;
ALTER TABLE `ne_state` DROP INDEX `idx_ne_type_id`;
ALTER TABLE `ne_state` DROP INDEX `idx_timestamp`;
ALTER TABLE `ne_state` MODIFY COLUMN `ne_type` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' AFTER `id`;
ALTER TABLE `ne_state` MODIFY COLUMN `ne_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' AFTER `ne_type`;
ALTER TABLE `ne_state` MODIFY COLUMN `version` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '版本' AFTER `ne_id`;
ALTER TABLE `ne_state` MODIFY COLUMN `capability` bigint(20) NULL DEFAULT 0 COMMENT '用户容量' AFTER `version`;
ALTER TABLE `ne_state` MODIFY COLUMN `serial_num` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '序列号' AFTER `capability`;
ALTER TABLE `ne_state` MODIFY COLUMN `expiry_date` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '许可证到期日期' AFTER `serial_num`;
ALTER TABLE `ne_state` ADD COLUMN `sys_cpu_usage` float NULL DEFAULT 0 COMMENT 'cpu使用率-sys' AFTER `expiry_date`;
ALTER TABLE `ne_state` ADD COLUMN `sys_mem_usage` float NULL DEFAULT 0 COMMENT '内存使用率-sys' AFTER `sys_cpu_usage`;
ALTER TABLE `ne_state` ADD COLUMN `sys_disk_usage` float NULL DEFAULT 0 COMMENT '磁盘使用率-sys' AFTER `sys_mem_usage`;
ALTER TABLE `ne_state` ADD COLUMN `nf_cpu_usage` float NULL DEFAULT 0 COMMENT 'cpu使用率-nf' AFTER `sys_disk_usage`;
ALTER TABLE `ne_state` ADD COLUMN `nf_mem_used` bigint(20) NULL DEFAULT 0 COMMENT '内存使用KB-nf' AFTER `nf_cpu_usage`;
ALTER TABLE `ne_state` ADD COLUMN `create_time` bigint(20) NULL DEFAULT 0 COMMENT '创建时间' AFTER `nf_mem_used`;
ALTER TABLE `ne_state` ADD INDEX `idx_type_id_time`(`ne_type`, `ne_id`, `create_time`) USING BTREE COMMENT 'idx_state_ne_type_id_at';
ALTER TABLE `ne_state` COMMENT = '网元_状态记录内存/CPU/磁盘';

SET FOREIGN_KEY_CHECKS=1;
