Bug: https://hola-tech.sg.larksuite.com/record/Y3nJrSQUPeRQDUc5Up1lZdRlgtd
Problem. Dashboard "Total cards" showed 17 (16 Active, 1 Blocked) but /cards was empty. The Cards page, its summary strip and the user cards panel only read user_cards.provider = 'reap'; CardsService.createCard never set that column (nullable, no default), so every app-issued card was stored NULL. The dashboard count had no provider filter. While reproducing this, three more defects on the same screens showed up: /cards/:id always said "Could not load card details." (the admin schemas rejected NULL card name/last 4/provider and the decimal-string spend limit pg returns), and sorting /cards by Balance or a ledger by amount returned 500 (TypeORM skip/take with a join cannot order its id subquery by a raw CAST).
Fix.
- be: UserCardProvider enum; createCard stamps the provider; migration 1790500000003 backfills NULL and case variants to reap and sets the column default (1 s lock_timeout, restored afterwards). The dashboard tile counts the same provider = reap cards the page lists. Balance/amount sorts go through a selected alias with an id tie-break; a NULL balance sorts, filters and summarises as 0 (the summary average/lowest now include unfunded cards).
- admin: schemas accept the NULL fields and string spend limit; a shared cardLabel renders missing parts as a dash on the list, detail and user pages.
Deploy note. The old API keeps serving during migration:run and saves whole card entities, so a card loaded before the backfill could be written back NULL. After deploy, SELECT id FROM user_cards WHERE provider IS NULL should return nothing; the migration UPDATE is safe to re-run.
Tests.
- Offline SQL spec on real TypeORM metadata (runs in CI) + 7 Postgres parity tests (RUN_DB_TESTS=1 yarn jest admin-reap-cards.postgres --runInBand); both fail on develop for the reported reasons.
- BE card/admin/dashboard/reap suites pass, nest build OK, tsc error count unchanged (89 = develop). Admin 834/834 tests, tsc clean, lint 0 errors.
- Playwright on the local admin console over cards written through the app path: tile 17 = table 17 = summary 17, Blocked filter 1, balance sort, card detail and user cards panel all render.
Not tested: staging data; the live Reap master-account balance (no Reap key locally).