Audit: add missing vendor/product indexes (products, show_inventory) + confirm 0031 applied on prod #417

Closed
opened 2026-08-21 01:56:34 +00:00 by gambit-admin · 2 comments
Owner

From the 8/18 audit follow-up (Scalability #1). Partially stale — PR #266 already added migration 0031_vendor_indexes (inventory_items, card_instances, intake_batch_items) — but two gaps remain:

  1. products and show_inventory still have no vendor index. Every list screen filters by vendor_id, so these are full-table scans. Add a migration: products (vendor_id), products (tcgplayer_product_id), products (card_number), products (game) (or a composite matching real query shapes — check the hot queries first), and show_inventory (vendor_id).
  2. Verify 0031 has actually been run on prod. It's a hand-run migration (Railway runs no migrations); written 8/18, may not be applied. Check alembic_version on prod before assuming.

At today's scale (~49 vendors) nothing hurts yet — the point is these are one hour now vs. an outage-shaped surprise at 10k vendors. Invisible failure mode per the audit: connection exhaustion, not gradual slowness.

Effort: ~1 hour + a prod migration run.


Filed from a Claude Code session

From the 8/18 audit follow-up (Scalability #1). Partially stale — PR #266 already added migration `0031_vendor_indexes` (inventory_items, card_instances, intake_batch_items) — but two gaps remain: 1. **`products` and `show_inventory` still have no vendor index.** Every list screen filters by vendor_id, so these are full-table scans. Add a migration: `products (vendor_id)`, `products (tcgplayer_product_id)`, `products (card_number)`, `products (game)` (or a composite matching real query shapes — check the hot queries first), and `show_inventory (vendor_id)`. 2. **Verify 0031 has actually been run on prod.** It's a hand-run migration (Railway runs no migrations); written 8/18, may not be applied. Check `alembic_version` on prod before assuming. At today's scale (~49 vendors) nothing hurts yet — the point is these are one hour now vs. an outage-shaped surprise at 10k vendors. Invisible failure mode per the audit: connection exhaustion, not gradual slowness. Effort: ~1 hour + a prod migration run. --- Filed from a Claude Code session
gambit-admin added the apiperformance labels 2026-08-21 01:56:34 +00:00
gambit-admin added the claimed:kris label 2026-08-21 02:06:37 +00:00
Author
Owner

Shipped in PR #278, released to prod via #279 (master d4050df, both Railway services deployed, /api/public/card probed 200). Migration 0032_vendor_lookup_indexes adds products (vendor_id, tcgplayer_product_id, card_number, game) + show_inventory (vendor_id); models carry matching index=True. NOTE: 0031+0032 still need the hand-run on prod (guarded script prepared; Kris runs it — session is blocked from prod DB).

Shipped in PR #278, released to prod via #279 (master d4050df, both Railway services deployed, /api/public/card probed 200). Migration 0032_vendor_lookup_indexes adds products (vendor_id, tcgplayer_product_id, card_number, game) + show_inventory (vendor_id); models carry matching index=True. NOTE: 0031+0032 still need the hand-run on prod (guarded script prepared; Kris runs it — session is blocked from prod DB).
gambit-admin removed the claimed:kris label 2026-08-21 02:52:06 +00:00
Author
Owner

Migration 0032 applied on prod (2026-08-20 evening): alembic_version now 0032_vendor_lookup_indexes; all five indexes verified present (ix_products_vendor_id / tcgplayer_product_id / card_number / game, ix_show_inventory_vendor_id). 0031's three were already applied. #417 fully done.

Migration 0032 applied on prod (2026-08-20 evening): alembic_version now 0032_vendor_lookup_indexes; all five indexes verified present (ix_products_vendor_id / tcgplayer_product_id / card_number / game, ix_show_inventory_vendor_id). 0031's three were already applied. #417 fully done.
Sign in to join this conversation.