-- ===== 下载去重记录（同一用户对同一 Skill 只计一次下载分） =====
CREATE TABLE IF NOT EXISTS skill_downloads (
  id         TEXT PRIMARY KEY,
  skill_id   TEXT NOT NULL,
  user_key   TEXT NOT NULL,  -- email 或 phone
  created_at INTEGER NOT NULL DEFAULT (strftime('%s','now')),
  UNIQUE(skill_id, user_key),
  FOREIGN KEY (skill_id) REFERENCES skills(id) ON DELETE CASCADE
);
CREATE INDEX IF NOT EXISTS idx_skill_downloads_skill ON skill_downloads(skill_id);
