Skip to content

migrations: Support graphical migrations

Administrator requested to merge ef/migration-graph into main

Created by: efritz

Pulled from #29831. This PR updates the remaining migration code to support a directed acyclic graph of migration definitions, rather than a linear chain. This change has several implications:

  • The migration_logs table, not the *schema_migrations table, is now the source-of-truth for the migration runner. We are unable to use the current schema migrations table (a single scalar value) to encode which set of migrations are applied.
    • Update documentation on how to deal with a new "dirty database" condition
      • #30760
  • sg migration add needed to be updated with knowledge of the graph structure
  • sg migration squash needed to be updated with knowledge of the graph structure
  • The "revert" needed to be updated with knowledge of the graph structure
  • The sg and migrator commands now accept multiple target revisions to migrate up or down to

Dry run: https://buildkite.com/sourcegraph/sourcegraph/builds/129142

Reviewers: Concentrate any energy on the runner package in its new state. I've tried to minimize the diff between the old and the new version, but they're quite different (and the new version is much simpler to reason about).

Merge request reports

Loading