migration: Make store initialization intelligent
Created by: efritz
Fixes #39579 (closed).
This PR makes the migration store backfill migration logs on startup. This has two effects:
- We can read from the
schema_versions
in older versions of Sourcegraph to determine which version they've migrated up to so far prior to an upgrade. - We can backfill the tail of the migration graph if a new instance starts prior to the first squash. This will help upgrades in the future so that we don't try to re-run migrations that were logically applied on the instance's first boot, but not explicitly listed in the migration logs of the first run.
Test plan
Additional unit tests in this PR.