fix(backfill-cli): wrap runBackfill in DatabaseContext.run

The orchestrator uses database() from ~/database/context, which requires
AsyncLocalStorage to be populated. Wrap the CLI invocation with
DatabaseContext.run(db, ...) using server/db's cached connection pool.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Chris Parsons 2026-05-01 21:01:13 +00:00
parent 6f3438b5d2
commit bc0f5301af
No known key found for this signature in database

View file

@ -8,6 +8,8 @@
* --apply is passed explicitly.
*/
import { DatabaseContext } from "~/database/context";
import { db } from "../server/db";
import { runBackfill } from "./backfill-canonical-layer";
import type { BackfillOptions } from "./backfill-canonical-layer";
@ -51,7 +53,7 @@ async function main() {
console.log(
`Running backfill (dryRun=${opts.dryRun}, sportId=${opts.sportId ?? "all"})`,
);
const report = await runBackfill(opts);
const report = await DatabaseContext.run(db, () => runBackfill(opts));
console.log("---");
console.log(`tournamentsCreated: ${report.tournamentsCreated}`);