migrations/*.sql.
Tables
races
Stores F1 race schedule and circuit information for each season.Auto-incrementing primary key
Year of the season (e.g., 2024)
Round number within the season (1-24)
Official race name (e.g., “Australian Grand Prix”)
Full circuit name (e.g., “Albert Park Circuit”)
Jolpica API circuit identifier (e.g., “albert_park”)
City or locality (e.g., “Melbourne”)
Country name (e.g., “Australia”)
Race date in ISO format (YYYY-MM-DD)
Race start time in UTC (HH:MM:SSZ), or NULL if unknown
Wikipedia article URL for the race
UNIQUE(season, round)— only one race per round per season- Index:
idx_races_season_roundon(season, round)
race_entries
Stores driver results for each race, including grid position, finish position, and points.Auto-incrementing primary key
Foreign key to
races.idJolpica API driver identifier (e.g., “max_verstappen”)
Three-letter driver code (e.g., “VER”, “HAM”)
Full driver name: “givenName familyName” (e.g., “Max Verstappen”)
Team/constructor name (e.g., “Red Bull”)
Starting grid position (1-20), or NULL if pit lane start
Final classification position, or NULL if DNF/DSQ/DNS
Finish status (e.g., “Finished”, “+1 Lap”, “Collision”, “Engine”)
Championship points earned (0.0-26.0 with fastest lap)
1 if driver set fastest lap, 0 otherwise
- Foreign key:
race_id REFERENCES races(id) - Index:
idx_race_entries_race_idonrace_id
standings_snapshots
Stores championship standings snapshots before and after each race for both drivers and constructors.Auto-incrementing primary key
Foreign key to
races.idWhen the snapshot was taken:
'before' or 'after'Type of entity:
'driver' or 'constructor'Championship position (1-20 for drivers, 1-10 for constructors)
Jolpica identifier (driver_id or constructor_id)
Display name for the driver or constructor
Total championship points at this snapshot
Total race wins at this snapshot
- Foreign key:
race_id REFERENCES races(id) - Check:
snapshot_type IN ('before', 'after') - Check:
entity_type IN ('driver', 'constructor') - Index:
idx_standings_snapshots_race_idonrace_id
TypeScript interfaces
The database row types are defined insrc/types.ts:
Migrations
The schema is versioned through numbered migration files:0000_baseline.sql— Creates initial tables and indexes0001_rename_columns.sql— Renamesraces.url→wikipedia_urlandrace_entries.driver_id→jolpica_driver_id
wrangler d1 migrations apply during deployment.
Relationships
- Each
racecan have multiplerace_entries(one per driver) - Each
racecan have multiplestandings_snapshots(before/after × driver/constructor) - All relationships use
race_idas the foreign key