-- 删除 users 表中的佣金相关字段
-- 注意：MySQL 5.7及以下版本不支持 DROP COLUMN IF EXISTS
-- 如果字段不存在，执行会报错，但可以忽略

-- 删除 commission 字段（如果存在）
SET @exist := (SELECT COUNT(*) FROM information_schema.COLUMNS 
               WHERE TABLE_SCHEMA = DATABASE() 
               AND TABLE_NAME = 'users' 
               AND COLUMN_NAME = 'commission');
SET @sqlstmt := IF(@exist > 0, 'ALTER TABLE users DROP COLUMN commission', 'SELECT "commission字段不存在，跳过删除"');
PREPARE stmt FROM @sqlstmt;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;

-- 删除 frozen_commission 字段（如果存在）
SET @exist := (SELECT COUNT(*) FROM information_schema.COLUMNS 
               WHERE TABLE_SCHEMA = DATABASE() 
               AND TABLE_NAME = 'users' 
               AND COLUMN_NAME = 'frozen_commission');
SET @sqlstmt := IF(@exist > 0, 'ALTER TABLE users DROP COLUMN frozen_commission', 'SELECT "frozen_commission字段不存在，跳过删除"');
PREPARE stmt FROM @sqlstmt;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;



