-- 用量（仅字节/分钟，无目的地）
CREATE TABLE usage_daily (
  user_id        INTEGER NOT NULL,
  date           DATE NOT NULL,
  bytes_up       INTEGER NOT NULL DEFAULT 0,
  bytes_down     INTEGER NOT NULL DEFAULT 0,
  minutes_used   INTEGER NOT NULL DEFAULT 0,
  ad_unlocked_at DATETIME NULL,
  PRIMARY KEY (user_id, date)
);

-- 审计
CREATE TABLE audit_log (
  id      INTEGER PRIMARY KEY AUTOINCREMENT,
  actor   TEXT NOT NULL,
  action  TEXT NOT NULL,
  target  TEXT NOT NULL,
  meta    TEXT NULL,                               -- JSON
  at      DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX idx_audit_at ON audit_log (at);
