Course Known-As Backfill
Repairs course.known_as_id — a self-referential FK on course
itself, sourced from tblcourses.KnowAsID, meant to link Turf/AW/Dirt
variants of the same physical venue: the "original" self-references, and every sibling
variant points known_as_id at the original's id. Confirmed live that the
destination value is currently just a raw, untranslated copy of the source
KnowAsID — never translated through config_id_mappings — which
produces valid-looking but wrong destination ids.
Two rules cover every row: if the source KnowAsID is a real value (whether
self-referencing or pointing at a sibling), it's translated through
config_id_mappings to get the correct destination id. If the source
KnowAsID is 0/NULL (no sibling recorded at all),
the correct value is the row's own destination id — a standalone course should still
self-reference rather than being left at 0. Only an already-resolvable
translation target is touched; a course whose sibling genuinely hasn't migrated yet is
left alone and counted as skipped, never auto-copied. Like Sales Lot Backfill and
Stewards Backfill, this feature has no date-floor/cutoff: course is static
reference/dimension data with no date column to scope by, so every run is a full,
unbounded sweep. This tool only ever issues UPDATE statements against
existing course rows — it never inserts or auto-copies a new one.
- Course → Course (self-ref) FK tblcourses.KnowAsID → course.known_as_id
Preview runs the exact same reads and resolves the exact same expected
values, but skips the actual write — no known_as_id 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.