-- 用量（最小数据原则：仅字节/分钟，无目的地）
CREATE TABLE usage_daily (
  user_id        BIGINT UNSIGNED NOT NULL,
  date           DATE NOT NULL,
  bytes_up       BIGINT UNSIGNED NOT NULL DEFAULT 0,
  bytes_down     BIGINT UNSIGNED NOT NULL DEFAULT 0,
  minutes_used   INT NOT NULL DEFAULT 0,
  ad_unlocked_at DATETIME(6) NULL,                 -- 免费版当日激励视频解锁时刻
  PRIMARY KEY (user_id, date)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- 审计（兑换/封禁/节点操作必记）
CREATE TABLE audit_log (
  id      BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  actor   VARCHAR(64) NOT NULL,
  action  VARCHAR(64) NOT NULL,
  target  VARCHAR(128) NOT NULL,
  meta    JSON NULL,
  at      DATETIME(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
  INDEX idx_at (at)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
