fix/bf-rollback
safecbdca09 · incrementalPR #259reviewed 2026-07-03 22:30 UTC0H · 0M · 0L · 2IThe branch
- Purpose
- Provides a tested rollback tool for the derived-concept backfill and fixes a real --rpu array-binding bug before running the backfill on prod.
- Goal
- Safe, reversible derived-bill-concept backfill: rollback tool + correct SQL param binding for --rpu/key array filters.
- Sub-goals
- SG-1: New rollback-derived-bill-concepts.ts — inverse of the backfill, same safety guards
- SG-2: Fix --rpu and key filters to bind each value as a scalar param via sql.join IN-lists
- SG-3: Extract shared CLI/SQL helpers (ops-guards.ts) into @batu/database, unit-tested
- SG-4: Test coverage for all ops-guards helpers
The changes (whole branch)
- What
- 5 commits: rollback script, --rpu binding fix, shared lib, ops-guards unit tests, final test tightening.
- Why
- The --rpu code path mis-serialized arrays under postgres.js. Rolling back required a proven inverse script before a prod run.
- Areas
- packages/database/package.json+4−0packages/database/src/__tests__/ops-guards.test.ts+153−0packages/database/src/ops-guards.ts+118−0scripts/backfill-derived-bill-concepts.ts+10−74scripts/lib/derived-bill-concepts.ts+25−0scripts/rollback-derived-bill-concepts.ts+86−0
- Blast
- 6 files, +396/−74 lines. Scripts + database test package only. No production handlers, schemas, or migrations touched.
ops-script no-migration test-only-final-commit
➖CI· No CI checks found➖CodeRabbit· No .coderabbit.yaml✅correctness✅security✅conventions✅tests✅improvement
Findings · 2
tests1
info
Error message assertion is loose — could also verify the bad value
packages/database/src/__tests__/ops-guards.test.ts:57
expect.stringContaining('--limit') is correct but does not verify the bad value is embedded in the diagnostic string.
improvement1
info
Duplicate error-path test scaffolding — could extract a helper
packages/database/src/__tests__/ops-guards.test.ts:53
Both exits-on-... tests share identical scaffolding. A small helper would remove ~8 lines of duplication.