SET FOREIGN_KEY_CHECKS=0;

-- ----------------------------
-- Table structure for ne_software
-- ----------------------------
CREATE TABLE IF NOT EXISTS `ne_software`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `ne_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '网元类型',
  `name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '包名称',
  `path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '包路径',
  `version` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '包版本',
  `description` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '包说明',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建者',
  `create_time` bigint NULL DEFAULT 0 COMMENT '创建时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '更新者',
  `update_time` bigint NULL DEFAULT 0 COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_type_name_version`(`ne_type` ASC, `name` ASC, `version` ASC) USING BTREE COMMENT '唯一网元类型和文件名版本是否唯一'
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '网元软件包' ROW_FORMAT = DYNAMIC;

-- 20240511前旧表更新
ALTER TABLE `ne_software` COMMENT = '网元软件包';
ALTER TABLE `ne_software` ADD COLUMN `name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '包名称' AFTER `ne_type`;
ALTER TABLE `ne_software` ADD COLUMN `description` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '包说明' AFTER `version`;
ALTER TABLE `ne_software` ADD COLUMN `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建者' AFTER `description`;
ALTER TABLE `ne_software` ADD COLUMN `create_time` bigint NULL DEFAULT 0 COMMENT '创建时间' AFTER `create_by`;
ALTER TABLE `ne_software` ADD COLUMN `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '更新者' AFTER `create_time`;
ALTER TABLE `ne_software` MODIFY COLUMN `ne_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '网元类型' AFTER `id`;
ALTER TABLE `ne_software` MODIFY COLUMN `path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '包路径' AFTER `name`;
ALTER TABLE `ne_software` MODIFY COLUMN `version` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '包版本' AFTER `path`;
ALTER TABLE `ne_software` MODIFY COLUMN `update_time` bigint NULL DEFAULT 0 COMMENT '更新时间' AFTER `update_by`;
ALTER TABLE `ne_software` DROP COLUMN `file_name`;
ALTER TABLE `ne_software` DROP COLUMN `md5_sum`;
ALTER TABLE `ne_software` DROP COLUMN `status`;
ALTER TABLE `ne_software` DROP COLUMN `comment`;
ALTER TABLE `ne_software` DROP COLUMN `patch_time`;
ALTER TABLE `ne_software` ADD UNIQUE INDEX `uk_type_name_version`(`ne_type` ASC, `name` ASC, `version` ASC) USING BTREE COMMENT '唯一网元类型和文件名版本是否唯一';

SET FOREIGN_KEY_CHECKS=1;
