← all branches

fix/bf-rollback

safe
cbdca09 · incrementalPR #259reviewed 2026-07-03 22:30 UTC0H · 0M · 0L · 2I
The 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+40packages/database/src/__tests__/ops-guards.test.ts+1530packages/database/src/ops-guards.ts+1180scripts/backfill-derived-bill-concepts.ts+1074scripts/lib/derived-bill-concepts.ts+250scripts/rollback-derived-bill-concepts.ts+860
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 foundCodeRabbit· No .coderabbit.yamlcorrectnesssecurityconventionstestsimprovement

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.

History · 5 commits

  1. cbdca09safeincremental0H · 0M · 0L2026-07-03 22:30current
  2. baca7afsafeincremental0H · 0M · 3L2026-07-03 21:27
  3. efb8a4fneeds attentionincremental0H · 1M · 7L2026-07-03 21:20
  4. b62fb9aneeds attentionincremental3H · 4M · 5L2026-07-03 21:04
  5. 0fd71fbneeds attentionfull0H · 4M · 2L2026-07-03 20:49