From bc0f5301afec77621348eb1502668951b411e3f7 Mon Sep 17 00:00:00 2001 From: Chris Parsons Date: Fri, 1 May 2026 21:01:13 +0000 Subject: [PATCH] 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 --- scripts/backfill-cli.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/backfill-cli.ts b/scripts/backfill-cli.ts index 4a6d3d0..ffdf42c 100644 --- a/scripts/backfill-cli.ts +++ b/scripts/backfill-cli.ts @@ -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}`);