feat(migrate): revision-chain ordering + struct-snapshot scaffolding#26
Merged
Conversation
This was referenced May 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds Alembic-style explicit revision-chain ordering and struct-snapshot migration scaffolding to the
migrateengine,migratecli, andmodusgraph-gen.Ordering — the revision chain
Migration.Afternames each migration's predecessor; exactly one root hasAfter == 0. The runner walks the chain instead of sorting by ID, so it catches parallel-branch divergence a timestamp sort hides.buildChainvalidates before any work and returns a typed error on the first fault:ErrDuplicateID,ErrNoRoot,ErrMultipleRoots,ErrUnknownPredecessor,ErrDivergentHistory,ErrCycle.up/down/statusnow order by the chain.Afteris folded into the migration checksum (structural → immutable once applied).migrate history [--tree] [--verbose]renders the chain, marks forks, and exits non-zero on a structural fault — a CI chain lint.Scaffolding
modusgraph-genemitsschema.Models() []any(one zero value per entity), so tooling cannot fall out of sync with the declared types.schema_state.schemais a checked-in, tool-managed desired-state snapshot.diffSchemaclassifies each predicate change: Added/IndexChanged → emitted as an additiveEnsureSchemadelta; TypeChanged/Removed → flagged forRetypePredicate/explicit drop, never auto-applied.Scaffold/Snapshot/Diffwrite the<id>_<name>.{go,schema}pair, advance the snapshot, and AST-append the new var to theAllslice (best-effort).ResolveDirfails fast with actionable messages outside a project root.Verifychecks the live schema against the structs (one-directional); detects Missing everywhere and Mismatched against a real Dgraph.CLI + docs
migratecli:create/diff [--check]/snapshot/verifycommands;ProvidergainsModels().diff --checkandverifyexit non-zero on drift.migrate/MIGRATIONS.mdlibrary guide + runnableExample*tests.Testing
go build ./... && go test ./...— all packages pass.