Mapping FK Sweep
Reads the newest rows of config_id_mappings (default 100,000, across every
table) and, for each one that belongs to a supported table, re-reads its
current source row, translates each FK through the
current parent mappings, and corrects any destination column that
disagrees. It is the same rule as Run, Trial Run, Race Meeting, Sales Lot, Stewards,
Reference, Racecard and Dividend Backfill (plus the reference and sales tables below), applied from the mappings side over a bounded
window of the most recently migrated rows. racecard_meeting.meeting_index_id
is deliberately not covered here — RacecardMeetingBackfill's own live preview found 99.4%
of in-scope rows still wrong after a full run, so its root cause may still be actively
producing bad data; this sweep won't also write to that column until that's understood.
jockey/trainer FKs are discipline-aware; every other FK accepts any of the parent's mapped destinations. A parent that was never migrated, or a source id of 0/-1, is left alone — nothing is auto-copied. Mapping rows for other tables are counted and skipped.
- run course_id, bonus_scheme_id, race_id, runner_id, jockey_id, trainer_id
- race rmeeting_id, course_id, country_id, feature_race_id
- meeting course_id, country_id
- course country_id, city_id
- feature_race course_id
- sales_lot runner_id, sale_id, session_id
- sales_sale company_id, country_id
- sales_session sale_id
- sales_company country_id
- stewards stew_runner_id
- jockey country_id
- trainer country_id
- runner trainer_id
- runner_lookup runner_id
- trainer_lookup source_trainer
- daylight_savings city_id
- racecard_meeting course_id
- racecard_race racecard_meeting_id, course_id, country_id, feature_race_id
- racecard_runner race_id, course_id, runner_id, jockey_id, trainer_id
- dividends meeting_id, race_id, country_id, racecard_race_id
Preview runs the exact same reads and resolves the exact same expected values, but skips the actual write — no column is changed. Use it to see what would change before committing to a real run.
Scheduled Backfill
Runs this same re-resolution pass automatically on a recurring interval instead of only ever running it by hand.