USE `lego`;

delete from t_atic_sysconfig where sys_var='scpFeedbackServerIP';
delete from t_atic_sysconfig where sys_var='scpFeedbackServerPort';

DROP PROCEDURE IF EXISTS del_device_esn;
DELIMITER //
CREATE PROCEDURE del_device_esn() BEGIN
    IF EXISTS(SELECT * FROM information_schema.columns
           WHERE table_name = 't_atic_device' AND column_name ='device_esn')
    THEN
        ALTER TABLE t_atic_device DROP COLUMN device_esn;
    END IF;
END;
//
DELIMITER ;
CALL del_device_esn();

DROP PROCEDURE IF EXISTS del_device_esn;


DROP PROCEDURE IF EXISTS del_ipreputation_type;
DELIMITER //
CREATE PROCEDURE del_ipreputation_type() BEGIN
    IF EXISTS(SELECT * FROM information_schema.columns
           WHERE table_name = 't_vsm_zone_ddos_policy' AND column_name ='ipreputation_service_type')
    THEN
        ALTER TABLE t_vsm_zone_ddos_policy DROP COLUMN ipreputation_service_type;
    END IF;
END;
//
DELIMITER ;
CALL del_ipreputation_type();

DROP PROCEDURE IF EXISTS del_ipreputation_type;


DROP PROCEDURE IF EXISTS del_ipreputation_enable;
DELIMITER //
CREATE PROCEDURE del_ipreputation_enable() BEGIN
    IF EXISTS(SELECT * FROM information_schema.columns
           WHERE table_name = 't_vsm_neconf_abnormaldfn' AND column_name ='ip_repuation_enable')
    THEN
        ALTER TABLE t_vsm_neconf_abnormaldfn DROP COLUMN ip_repuation_enable;
		ALTER TABLE t_vsm_neconf_abnormaldfn DROP COLUMN gray_threshold;
		ALTER TABLE t_vsm_neconf_abnormaldfn DROP COLUMN black_threshold;
		ALTER TABLE t_vsm_neconf_abnormaldfn DROP COLUMN statistics_feedback;
		ALTER TABLE t_vsm_neconf_abnormaldfn DROP COLUMN sample_rate;
    END IF;
END;
//
DELIMITER ;
CALL del_ipreputation_enable();

DROP PROCEDURE IF EXISTS del_ipreputation_enable;