-- 榜单周期冻结与钱包发奖解耦：job 独立租约允许水平扩展，退避/终态避免钱包故障时形成重试风暴。
ALTER TABLE activity_template_reward_jobs
  ADD COLUMN max_attempts INT NOT NULL DEFAULT 8
    COMMENT '自动投递总尝试上限；dead 手工复活时只扩一轮预算' AFTER attempt_count,
  ADD COLUMN next_retry_at_ms BIGINT NOT NULL DEFAULT 0
    COMMENT '下一次可领取时间，UTC epoch ms' AFTER max_attempts,
  ADD COLUMN locked_by VARCHAR(128) NOT NULL DEFAULT ''
    COMMENT '当前 job lease owner' AFTER next_retry_at_ms,
  ADD COLUMN lock_until_ms BIGINT NOT NULL DEFAULT 0
    COMMENT 'job lease 过期时间，UTC epoch ms' AFTER locked_by,
  ADD KEY idx_activity_template_reward_claim
    (app_code, status, next_retry_at_ms, lock_until_ms, created_at_ms, reward_job_id);
