USE `data_center_new`;

DROP procedure IF EXISTS `add_column`;

DELIMITER $$

CREATE PROCEDURE add_column()

BEGIN
    IF NOT EXISTS (
        SELECT * 
        FROM information_schema.columns 
        WHERE table_schema = 'data_center_new' 
        AND table_name = 'basic_monitoring_asset' 
        AND column_name = 's3_file_name'
    ) THEN
        ALTER TABLE basic_monitoring_asset 
        ADD COLUMN `s3_file_name` text COMMENT 's3存储的资料文件名';
    END IF;
    
    IF NOT EXISTS (
        SELECT * 
        FROM information_schema.columns 
        WHERE table_schema = 'data_center_new' 
        AND table_name = 'basic_monitoring_asset' 
        AND column_name = 'mapper_file_name'
    ) THEN
        ALTER TABLE basic_monitoring_asset 
        ADD COLUMN `mapper_file_name` text COMMENT 's3资料文件名与原始资料文件名的映射关系';
    END IF;
    
END$$

DELIMITER ;


CALL add_column();

DROP procedure IF EXISTS `add_column`;