-- #197. Token bucket state for §15's provider and translator budgets. The -- allowance itself is `subtitle_settings.provider_daily_budgets` / -- `translator_daily_budgets` (#198); this table only tracks what has already -- been spent today, so a bucket with no allowance configured reads as -- unlimited rather than zero (0025's own comment on that column). -- -- One row per (kind, name, day); a new day is a fresh row rather than a -- reset column, so the refill is "today has no row yet" and needs no cron. CREATE TABLE subtitle_budget_spend ( kind TEXT NOT NULL CHECK (kind IN ('provider', 'translator')), name TEXT NOT NULL, -- UTC calendar day, `YYYY-MM-DD`. day TEXT NOT NULL, -- A provider unit is one download; a translator unit is one character of -- source text sent (DESIGN.md §15: translators bill per character). spent INTEGER NOT NULL DEFAULT 0 CHECK (spent >= 0), PRIMARY KEY (kind, name, day) ) STRICT;