SET NAMES utf8mb4;

ALTER TABLE voice_room_red_packet_config
  MODIFY COLUMN id BIGINT NOT NULL COMMENT '主键ID',
  MODIFY COLUMN sys_origin VARCHAR(32) NOT NULL COMMENT '系统来源',
  MODIFY COLUMN enabled TINYINT(1) NOT NULL DEFAULT 1 COMMENT '是否启用语音房红包',
  MODIFY COLUMN daily_send_limit INT NOT NULL DEFAULT 10 COMMENT '用户每日发红包次数上限',
  MODIFY COLUMN delay_seconds INT NOT NULL DEFAULT 300 COMMENT '延迟红包可领取等待秒数',
  MODIFY COLUMN refund_after_seconds INT NOT NULL DEFAULT 7200 COMMENT '红包领取开始后多少秒过期退款',
  MODIFY COLUMN timezone VARCHAR(64) NOT NULL DEFAULT 'Asia/Riyadh' COMMENT '业务时区，用于每日限额统计',
  MODIFY COLUMN amount_options VARCHAR(255) NOT NULL DEFAULT '15000,30000,70000,100000' COMMENT '可选红包总金额列表，逗号分隔',
  MODIFY COLUMN count_options VARCHAR(255) NOT NULL DEFAULT '5,10,20,50' COMMENT '可选红包份数列表，逗号分隔',
  MODIFY COLUMN create_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  MODIFY COLUMN update_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  COMMENT = '语音房红包配置表';

ALTER TABLE voice_room_region_country
  MODIFY COLUMN id BIGINT NOT NULL COMMENT '主键ID',
  MODIFY COLUMN sys_origin VARCHAR(32) NOT NULL COMMENT '系统来源',
  MODIFY COLUMN region_code VARCHAR(32) NOT NULL COMMENT '区域编码',
  MODIFY COLUMN country_code VARCHAR(32) NOT NULL COMMENT '国家编码',
  MODIFY COLUMN enabled TINYINT(1) NOT NULL DEFAULT 1 COMMENT '是否启用该国家区域映射',
  MODIFY COLUMN create_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  MODIFY COLUMN update_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  COMMENT = '语音房国家区域映射表';

ALTER TABLE voice_room_red_packet
  MODIFY COLUMN id BIGINT NOT NULL COMMENT '主键ID',
  MODIFY COLUMN packet_no VARCHAR(64) NOT NULL COMMENT '红包业务编号',
  MODIFY COLUMN request_id VARCHAR(128) NOT NULL COMMENT '客户端幂等请求ID',
  MODIFY COLUMN sys_origin VARCHAR(32) NOT NULL COMMENT '系统来源',
  MODIFY COLUMN room_id BIGINT NOT NULL COMMENT '语音房ID',
  MODIFY COLUMN sender_user_id BIGINT NOT NULL COMMENT '发红包用户ID',
  MODIFY COLUMN sender_region_code VARCHAR(32) NOT NULL COMMENT '发红包用户区域编码',
  MODIFY COLUMN packet_mode VARCHAR(16) NOT NULL COMMENT '红包模式：IMMEDIATE立即，DELAYED延迟',
  MODIFY COLUMN amount_mode VARCHAR(16) NOT NULL DEFAULT 'RANDOM' COMMENT '金额分配模式：RANDOM随机',
  MODIFY COLUMN total_amount BIGINT NOT NULL COMMENT '红包总金额，单位金币',
  MODIFY COLUMN total_count INT NOT NULL COMMENT '红包总份数',
  MODIFY COLUMN remain_amount BIGINT NOT NULL COMMENT '剩余未领取金额，单位金币',
  MODIFY COLUMN remain_count INT NOT NULL COMMENT '剩余未领取份数',
  MODIFY COLUMN claim_start_time DATETIME NOT NULL COMMENT '可开始领取时间',
  MODIFY COLUMN expire_time DATETIME NOT NULL COMMENT '过期退款时间',
  MODIFY COLUMN status VARCHAR(32) NOT NULL COMMENT '红包状态：INIT/ACTIVE/FINISHED/EXPIRED/REFUNDED/REFUND_FAILED/FAILED',
  MODIFY COLUMN send_wallet_event_id VARCHAR(128) NOT NULL COMMENT '发红包扣款钱包事件ID',
  MODIFY COLUMN refund_wallet_event_id VARCHAR(128) DEFAULT NULL COMMENT '退款钱包事件ID',
  MODIFY COLUMN refund_amount BIGINT NOT NULL DEFAULT 0 COMMENT '退款金额，单位金币',
  MODIFY COLUMN refund_status VARCHAR(32) NOT NULL DEFAULT 'NONE' COMMENT '退款状态：NONE/PENDING/SUCCESS/FAILED',
  MODIFY COLUMN error_message VARCHAR(1024) DEFAULT NULL COMMENT '异常信息',
  MODIFY COLUMN create_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  MODIFY COLUMN update_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  COMMENT = '语音房红包主表';

ALTER TABLE voice_room_red_packet_slice
  MODIFY COLUMN id BIGINT NOT NULL COMMENT '主键ID',
  MODIFY COLUMN packet_id BIGINT NOT NULL COMMENT '红包主表ID',
  MODIFY COLUMN packet_no VARCHAR(64) NOT NULL COMMENT '红包业务编号',
  MODIFY COLUMN sort_no INT NOT NULL COMMENT '红包份额序号',
  MODIFY COLUMN amount BIGINT NOT NULL COMMENT '份额金额，单位金币',
  MODIFY COLUMN status VARCHAR(32) NOT NULL DEFAULT 'UNCLAIMED' COMMENT '份额状态：UNCLAIMED/CLAIMING/CLAIMED/RELEASED',
  MODIFY COLUMN claim_user_id BIGINT DEFAULT NULL COMMENT '领取用户ID',
  MODIFY COLUMN claim_record_id BIGINT DEFAULT NULL COMMENT '领取记录ID',
  MODIFY COLUMN create_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  MODIFY COLUMN update_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  COMMENT = '语音房红包份额表';

ALTER TABLE voice_room_red_packet_claim
  MODIFY COLUMN id BIGINT NOT NULL COMMENT '主键ID',
  MODIFY COLUMN packet_id BIGINT NOT NULL COMMENT '红包主表ID',
  MODIFY COLUMN packet_no VARCHAR(64) NOT NULL COMMENT '红包业务编号',
  MODIFY COLUMN slice_id BIGINT NOT NULL COMMENT '红包份额ID',
  MODIFY COLUMN sys_origin VARCHAR(32) NOT NULL COMMENT '系统来源',
  MODIFY COLUMN room_id BIGINT NOT NULL COMMENT '语音房ID',
  MODIFY COLUMN user_id BIGINT NOT NULL COMMENT '领取用户ID',
  MODIFY COLUMN user_region_code VARCHAR(32) NOT NULL COMMENT '领取用户区域编码',
  MODIFY COLUMN amount BIGINT NOT NULL COMMENT '领取金额，单位金币',
  MODIFY COLUMN wallet_event_id VARCHAR(128) NOT NULL COMMENT '领取入账钱包事件ID',
  MODIFY COLUMN wallet_status VARCHAR(32) NOT NULL COMMENT '钱包入账状态：PENDING/SUCCESS/FAILED',
  MODIFY COLUMN error_message VARCHAR(1024) DEFAULT NULL COMMENT '异常信息',
  MODIFY COLUMN claim_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '领取时间',
  MODIFY COLUMN create_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  MODIFY COLUMN update_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  COMMENT = '语音房红包领取记录表';

ALTER TABLE voice_room_red_packet_daily_counter
  MODIFY COLUMN id BIGINT NOT NULL COMMENT '主键ID',
  MODIFY COLUMN sys_origin VARCHAR(32) NOT NULL COMMENT '系统来源',
  MODIFY COLUMN user_id BIGINT NOT NULL COMMENT '用户ID',
  MODIFY COLUMN day_key VARCHAR(16) NOT NULL COMMENT '统计日期，格式yyyyMMdd',
  MODIFY COLUMN send_count INT NOT NULL DEFAULT 0 COMMENT '当日已发送红包次数',
  MODIFY COLUMN create_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  MODIFY COLUMN update_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  COMMENT = '语音房红包每日发送计数表';

ALTER TABLE voice_room_region_im_group
  MODIFY COLUMN id BIGINT NOT NULL COMMENT '主键ID',
  MODIFY COLUMN sys_origin VARCHAR(32) NOT NULL COMMENT '系统来源',
  MODIFY COLUMN region_code VARCHAR(32) NOT NULL COMMENT '区域编码',
  MODIFY COLUMN region_name VARCHAR(128) NOT NULL DEFAULT '' COMMENT '区域名称',
  MODIFY COLUMN group_id VARCHAR(128) NOT NULL DEFAULT '' COMMENT '腾讯 IM 群组ID',
  MODIFY COLUMN group_name VARCHAR(128) NOT NULL DEFAULT '' COMMENT '腾讯 IM 群组名称',
  MODIFY COLUMN status VARCHAR(32) NOT NULL DEFAULT 'PENDING' COMMENT '群组状态：PENDING/ACTIVE/FAILED',
  MODIFY COLUMN last_error VARCHAR(1024) NOT NULL DEFAULT '' COMMENT '最近一次创建或同步失败原因',
  MODIFY COLUMN create_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  MODIFY COLUMN update_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  COMMENT = '语音房区域通用 IM 群组表';
