← Statpro dev log

Bootstrapping NFL 2026: a migration that knows it already ran

#sports#data#infra#automation

A grid of dim round nodes with one glowing amber node, fed by two small pills whose lines merge into it.

A new NFL season needs fresh canonical identity rows for every team, player and game. That is the one authoritative record each of them gets, which every other table points to. Rosters change, players who share a name need distinct slugs, and the schedule is new. A setup job that big will get run more than once, so I wanted a second run to be provably harmless.

One transaction, one receipt

The bootstrap on Statpro, my sports stats site, creates team crosswalks, which map each data source's team codes to mine, along with player profiles and game rows in a single serializable transaction. It uses a five-second lock timeout, so a second attempt that collides with the first backs off quickly. When it finishes, it produces a hashed receipt of what it did:

type BootstrapReceipt = {
  season: number;
  counts: Record<CountName, number>;
  bootstrapHash: string;
  disposition: "planned" | "created" | "exact_replay";
};

The disposition, which says what the run did, is the useful field. exact_replay means the target state already matches and nothing was touched.

The AZ problem

One of the 32 teams tripped it. The Arizona Cardinals arrive from the data source with its code AZ, and the canonical code, the one my site uses everywhere, is ARI. Last season's bootstrap never hit this because the team already existed. The fix is one line:

function canonicalTeamCode(sourceCode: string): string {
  return sourceCode === "AZ" ? "ARI" : sourceCode;
}

Replays only match when evidence is deterministic

Each identity fact the bootstrap creates is backed by recorded evidence with a count, an order and a timestamp. Five follow-up commits fixed how those verified facts survive a migration replay: replay permission, date readback, evidence count, evidence clock and evidence ordering. They share a cause. If evidence isn't ordered and counted the same way every time, the replay hash differs and a harmless re-run looks like a change.

The part I'd reuse anywhere: have a migration hash what it did, and teach it to recognize an identical re-run. Then "did this already run?" has an answer you can check.

This is the build log for Statpro (statpro.io) · All entries · Weekly essays