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(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci 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 DEFAULT '' COMMENT '包说明',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '创建者',
  `create_time` bigint DEFAULT '0' COMMENT '创建时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '更新者',
  `update_time` bigint DEFAULT '0' COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE KEY `uk_type_name_version` (`ne_type`,`name`,`version`) USING BTREE COMMENT '唯一网元类型和文件名版本是否唯一'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='网元软件包';

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

SET FOREIGN_KEY_CHECKS=1;
