Audit: add missing vendor/product indexes (products, show_inventory) + confirm 0031 applied on prod #417
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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:productsandshow_inventorystill 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), andshow_inventory (vendor_id).alembic_versionon 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
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).
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.