migrations: Validate cycles
Created by: efritz
Pulled from #29831. This PR reads multiple parent values from migration metadata files, and validates that the resulting migration tree is a single-root connected acyclic graph. Non-test code still requires a linear chain of migrations, so we're not yet at the final stage (and no consumers are yet required to work nicely with multiple parents).
This PR takes care to make very actionable error messages when cycles do occur so that developers are able to self-serve their way to a valid migration state.
Reviewers: Review-by-commit may be cleaner but might not be necessary.