-- =====================================================
-- 武术比赛管理系统 - 补充裁判邀请表字段
-- 添加实体类中存在但数据库表缺失的字段
-- Date: 2025-12-12
-- =====================================================

USE martial_db;

-- =====================================================
-- martial_judge_invite (裁判邀请码表) - 添加缺失字段
-- =====================================================

-- 添加 invite_status 字段
ALTER TABLE martial_judge_invite
ADD COLUMN invite_status int DEFAULT 0 COMMENT '邀请状态(0-待回复,1-已接受,2-已拒绝,3-已取消)' AFTER token_expire_time;

-- 添加 invite_time 字段
ALTER TABLE martial_judge_invite
ADD COLUMN invite_time datetime DEFAULT NULL COMMENT '邀请时间' AFTER invite_status;

-- 添加 reply_time 字段
ALTER TABLE martial_judge_invite
ADD COLUMN reply_time datetime DEFAULT NULL COMMENT '回复时间' AFTER invite_time;

-- 添加 reply_note 字段
ALTER TABLE martial_judge_invite
ADD COLUMN reply_note varchar(500) DEFAULT NULL COMMENT '回复备注' AFTER reply_time;

-- 添加 contact_phone 字段
ALTER TABLE martial_judge_invite
ADD COLUMN contact_phone varchar(20) DEFAULT NULL COMMENT '联系电话' AFTER reply_note;

-- 添加 contact_email 字段
ALTER TABLE martial_judge_invite
ADD COLUMN contact_email varchar(100) DEFAULT NULL COMMENT '联系邮箱' AFTER contact_phone;

-- 添加 invite_message 字段
ALTER TABLE martial_judge_invite
ADD COLUMN invite_message varchar(1000) DEFAULT NULL COMMENT '邀请消息' AFTER contact_email;

-- 添加 cancel_reason 字段
ALTER TABLE martial_judge_invite
ADD COLUMN cancel_reason varchar(500) DEFAULT NULL COMMENT '取消原因' AFTER invite_message;

-- =====================================================
-- 验证修改
-- =====================================================
SELECT '=== 裁判邀请表字段补充完成 ===' AS status;

-- 查看表结构
SHOW COLUMNS FROM martial_judge_invite;

-- 统计字段数量
SELECT
    'martial_judge_invite 字段数:' AS info,
    COUNT(*) AS count
FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA='martial_db'
AND TABLE_NAME='martial_judge_invite';
