SET @db = DATABASE();

SET @sql = IF(
    EXISTS(
        SELECT 1 FROM information_schema.COLUMNS
        WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'gxmu_wxxzx_project' AND COLUMN_NAME = 'funding_budget_file'
    ),
    'SELECT 1',
    'ALTER TABLE gxmu_wxxzx_project ADD COLUMN funding_budget_file VARCHAR(500) NULL COMMENT ''经费预算表'''
);
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;

SET @sql = IF(
    EXISTS(
        SELECT 1 FROM information_schema.COLUMNS
        WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'gxmu_wxxzx_project' AND COLUMN_NAME = 'funding_allocation_file'
    ),
    'SELECT 1',
    'ALTER TABLE gxmu_wxxzx_project ADD COLUMN funding_allocation_file VARCHAR(500) NULL COMMENT ''经费划拨明细表'''
);
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;

SET @sql = IF(
    EXISTS(
        SELECT 1 FROM information_schema.COLUMNS
        WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'gxmu_wxxzx_project' AND COLUMN_NAME = 'midterm_remark'
    ),
    'SELECT 1',
    'ALTER TABLE gxmu_wxxzx_project ADD COLUMN midterm_remark TEXT NULL COMMENT ''中期检查说明'''
);
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;

SET @sql = IF(
    EXISTS(
        SELECT 1 FROM information_schema.COLUMNS
        WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'gxmu_wxxzx_project' AND COLUMN_NAME = 'midterm_materials'
    ),
    'SELECT 1',
    'ALTER TABLE gxmu_wxxzx_project ADD COLUMN midterm_materials LONGTEXT NULL COMMENT ''中期检查材料(JSON字符串)'''
);
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;

SET @sql = IF(
    EXISTS(
        SELECT 1 FROM information_schema.COLUMNS
        WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'gxmu_wxxzx_project' AND COLUMN_NAME = 'final_remark'
    ),
    'SELECT 1',
    'ALTER TABLE gxmu_wxxzx_project ADD COLUMN final_remark TEXT NULL COMMENT ''结题说明'''
);
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;

SET @sql = IF(
    EXISTS(
        SELECT 1 FROM information_schema.COLUMNS
        WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'gxmu_wxxzx_project' AND COLUMN_NAME = 'final_materials'
    ),
    'SELECT 1',
    'ALTER TABLE gxmu_wxxzx_project ADD COLUMN final_materials LONGTEXT NULL COMMENT ''结题材料(JSON字符串)'''
);
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;

SET @sql = IF(
    EXISTS(
        SELECT 1 FROM information_schema.COLUMNS
        WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'gxmu_wxxzx_project' AND COLUMN_NAME = 'archive_awards'
    ),
    'SELECT 1',
    'ALTER TABLE gxmu_wxxzx_project ADD COLUMN archive_awards TEXT NULL COMMENT ''获奖情况'''
);
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;

SET @sql = IF(
    EXISTS(
        SELECT 1 FROM information_schema.COLUMNS
        WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'gxmu_wxxzx_project' AND COLUMN_NAME = 'archive_proofs'
    ),
    'SELECT 1',
    'ALTER TABLE gxmu_wxxzx_project ADD COLUMN archive_proofs LONGTEXT NULL COMMENT ''佐证材料(JSON字符串)'''
);
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
