-- Kit usage tracking schema
-- Run: wrangler d1 execute vibery-stats --file=migrations/0002_kit_usage_stats.sql

CREATE TABLE IF NOT EXISTS kit_usage_counts (
  kit_id TEXT PRIMARY KEY,
  copies INTEGER DEFAULT 0,
  downloads INTEGER DEFAULT 0,
  total INTEGER GENERATED ALWAYS AS (copies + downloads) STORED
);

CREATE INDEX IF NOT EXISTS idx_kit_total ON kit_usage_counts(total DESC);
