SET FOREIGN_KEY_CHECKS=0;

-- ----------------------------
-- Table structure for ne_license
-- ----------------------------
CREATE TABLE IF NOT EXISTS `ne_license`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `ne_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '网元类型',
  `ne_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '网元ID',
  `activation_request_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '激活申请代码',
  `license_path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '激活授权文件',
  `serial_num` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '-' COMMENT '序列号',
  `expiry_date` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '-' COMMENT '许可证到期日期',
  `status` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '状态 0无效 1有效',
  `remark` varchar(255) 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_id` (`ne_type`,`ne_id`) USING BTREE COMMENT '唯一网元类型和网元ID'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='网元授权激活信息';

-- 20240511前旧表更新
ALTER TABLE `ne_license` COMMENT = '网元授权激活信息';
ALTER TABLE `ne_license` ADD COLUMN IF NOT EXISTS `activation_request_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '激活申请代码' AFTER `ne_id`;
ALTER TABLE `ne_license` ADD COLUMN IF NOT EXISTS `license_path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '激活授权文件' AFTER `activation_request_code`;
ALTER TABLE `ne_license` ADD COLUMN IF NOT EXISTS `serial_num` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '-' COMMENT '序列号' AFTER `license_path`;
ALTER TABLE `ne_license` ADD COLUMN IF NOT EXISTS `expiry_date` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '-' COMMENT '许可证到期日期' AFTER `serial_num`;
ALTER TABLE `ne_license` ADD COLUMN IF NOT EXISTS `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '备注' AFTER `status`;
ALTER TABLE `ne_license` ADD COLUMN IF NOT EXISTS `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建者' AFTER `remark`;
ALTER TABLE `ne_license` ADD COLUMN IF NOT EXISTS `create_time` bigint NULL DEFAULT 0 COMMENT '创建时间' AFTER `create_by`;
ALTER TABLE `ne_license` 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_license` ADD COLUMN IF NOT EXISTS `update_time` bigint NULL DEFAULT 0 COMMENT '更新时间' AFTER `update_by`;
ALTER TABLE `ne_license` MODIFY COLUMN `ne_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '网元类型' AFTER `id`;
ALTER TABLE `ne_license` MODIFY COLUMN `ne_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '网元ID' AFTER `ne_type`;
ALTER TABLE `ne_license` MODIFY COLUMN `status` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '状态 0无效 1有效' AFTER `expiry_date`;
ALTER TABLE `ne_license` DROP COLUMN IF EXISTS `serial_no`;
ALTER TABLE `ne_license` DROP COLUMN IF EXISTS `capcity`;
ALTER TABLE `ne_license` DROP COLUMN IF EXISTS `used`;
ALTER TABLE `ne_license` DROP COLUMN IF EXISTS `feature_enabled`;
ALTER TABLE `ne_license` DROP COLUMN IF EXISTS `expiration_date`;
ALTER TABLE `ne_license` DROP COLUMN IF EXISTS `path`;
ALTER TABLE `ne_license` DROP COLUMN IF EXISTS `file_name`;
ALTER TABLE `ne_license` DROP COLUMN IF EXISTS `comment`;
ALTER TABLE `ne_license` DROP COLUMN IF EXISTS `created_at`;
ALTER TABLE `ne_license` DROP COLUMN IF EXISTS `updated_at`;
ALTER TABLE `ne_license` DROP COLUMN IF EXISTS `deleted_at`;
ALTER TABLE `ne_license` ADD UNIQUE INDEX IF NOT EXISTS `uk_type_id`(`ne_type` ASC, `ne_id` ASC) USING BTREE COMMENT '唯一网元类型和网元ID';


SET FOREIGN_KEY_CHECKS=1;
