DROP TRIGGER IF EXISTS `tg_account_menu`;

ALTER TABLE `omc_db`.`gold_kpi` 
MODIFY COLUMN `value` bigint NULL DEFAULT 0 AFTER `kpi_id`;

ALTER TABLE `omc_db`.`user` 
DROP INDEX IF EXISTS `account_id`,
DROP INDEX IF EXISTS `idx_uni_user_acc_id`,
ADD UNIQUE INDEX `idx_uni_user_acc_id`(`account_id`) USING BTREE;

ALTER TABLE `omc_db`.`ne_link` DROP INDEX IF EXISTS `idx_netype_neid`;

ALTER TABLE `omc_db`.`user` 
MODIFY COLUMN `password_expiration` date NULL DEFAULT NULL AFTER `change_password_flag`,
MODIFY COLUMN `user_expiration` date NULL DEFAULT NULL AFTER `status`;

ALTER TABLE `omc_db`.`config` 
ADD COLUMN IF NOT EXISTS `comment` varchar(255) NULL AFTER `update_time`;

ALTER TABLE `omc_db`.`nbi_operation_log` 
MODIFY COLUMN `created_at` datetime NULL DEFAULT NULL AFTER `log_time`;

ALTER TABLE `omc_db`.`permission` 
ADD COLUMN IF NOT EXISTS `management` varchar(32) NULL DEFAULT '*' AFTER `method`;

ALTER TABLE `omc_db`.`permission` 
CHANGE COLUMN IF EXISTS `create_at` `created_at` datetime NULL DEFAULT current_timestamp AFTER `description`,
MODIFY COLUMN `method` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '*' AFTER `permission_name`,
MODIFY COLUMN `management` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '*' AFTER `method`,
MODIFY COLUMN `element` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '*' AFTER `management`,
MODIFY COLUMN `object` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '*' AFTER `element`,
ADD COLUMN IF NOT EXISTS `updated_at` datetime NULL AFTER `created_at`,
ADD COLUMN IF NOT EXISTS `deleted_at` datetime NULL AFTER `updated_at`;

ALTER TABLE `omc_db`.`permission` 
DROP INDEX IF EXISTS `permission_name`,
ADD UNIQUE INDEX `permission_name`(`permission_name`) USING BTREE;

ALTER TABLE `omc_db`.`ne_software` 
DROP COLUMN IF EXISTS `patch_time`,
ADD COLUMN IF NOT EXISTS `patch_time` datetime NULL AFTER `update_time`;

ALTER TABLE `omc_db`.`alarm_log` 
DROP COLUMN IF EXISTS`alarm_seq`,
ADD COLUMN `alarm_seq` int NULL AFTER `ne_id`;

ALTER TABLE `omc_db`.`ne_software` 
DROP COLUMN IF EXISTS `patch_time`,
ADD COLUMN `patch_time` datetime NULL AFTER `update_time`;

ALTER TABLE `omc_db`.`nbi_alarm_log` 
DROP COLUMN IF EXISTS `alarm_status`,
ADD COLUMN `alarm_status` int NULL COMMENT '0/1: 清除告警/活动告警' AFTER `alarm_code`;

ALTER TABLE `omc_db`.`cert_info` DROP INDEX IF EXISTS `idx_netype_neid`;

ALTER TABLE `omc_db`.`user` 
MODIFY COLUMN `name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL AFTER `account_id`;