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:
parent
6f3438b5d2
commit
bc0f5301af
1 changed files with 3 additions and 1 deletions
|
|
@ -8,6 +8,8 @@
|
||||||
* --apply is passed explicitly.
|
* --apply is passed explicitly.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { DatabaseContext } from "~/database/context";
|
||||||
|
import { db } from "../server/db";
|
||||||
import { runBackfill } from "./backfill-canonical-layer";
|
import { runBackfill } from "./backfill-canonical-layer";
|
||||||
import type { BackfillOptions } from "./backfill-canonical-layer";
|
import type { BackfillOptions } from "./backfill-canonical-layer";
|
||||||
|
|
||||||
|
|
@ -51,7 +53,7 @@ async function main() {
|
||||||
console.log(
|
console.log(
|
||||||
`Running backfill (dryRun=${opts.dryRun}, sportId=${opts.sportId ?? "all"})`,
|
`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("---");
|
||||||
console.log(`tournamentsCreated: ${report.tournamentsCreated}`);
|
console.log(`tournamentsCreated: ${report.tournamentsCreated}`);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue