chore(db): drop songstats_quota_ledger table (chat#1797 — bullet 2)

Merged
SW
4mo ago
+16-0

What

Bullet 2 of recoupable/chat#1797 (database half): drop the songstats_quota_ledger table.

The local ledger mirrored Songstats' rate quota so a budget gate could halt the backfill drain. In practice it drifted — the prod 429 storm (2026-06) filled it with phantom 429 "hits" (a row was inserted on every Songstats call, success or not), so the gate tripped on rate-limit noise rather than real quota, halting the drain prematurely. Songstats is the rate authority; api now relies on per-track bounded exponential backoff and defers rate-limited rows to the next run.

⚠️ Apply order

Deploy api#674 first (removes all reads/writes of the ledger), then apply this migration. Dropping the table while the live api still inserts into it would error every backfill call. Not yet applied to prod — sequenced behind the api deploy.

Changes

  • 20260616000000_drop_songstats_quota_ledger.sql — DROP TABLE IF EXISTS public.songstats_quota_ledger CASCADE;

Related

Closes the database half of bullet 2 of recoupable/chat#1797.


Summary by cubic

Drops the songstats_quota_ledger table to remove the drift‑prone local quota ledger and rely on Songstats + per‑track bounded backoff. Implements bullet 2 of chat#1797.

  • Migration
    • Deploy api#674 first (stops all ledger reads/writes), then apply this migration.
    • Drops public.songstats_quota_ledger with CASCADE to clean up related objects.