feat: AlterSchema, dropPredicate, and embedded DropAttr#24
Open
mlwelles wants to merge 2 commits into
Open
Conversation
Adds raw schema-DDL primitives that complement UpdateSchema's object-template inference: - Client.AlterSchema(ctx, schema) applies a raw DQL schema string directly, giving full control over predicate types, indexes, and directives — useful for migrations that declare predicates no Go type models yet. - Engine.dropPredicate deletes a single predicate (and its data) from the embedded engine via posting.DeletePredicate. - embedded_client.go routes an Alter carrying DropAttr to dropPredicate, so the embedded path matches a remote Dgraph cluster's DropAttr behavior. TestDropPredicateEmbedded exercises the full declare/insert/drop cycle against the embedded engine.
Document the raw schema-DDL path with a runnable example showing predicate types, indexes, and directives applied directly via AlterSchema.
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.
What this adds
Raw schema-DDL primitives that complement
UpdateSchema's struct-tag inference,plus matching
DropAttrsupport for the embedded engine.Client.AlterSchema(ctx, schema string)— applies a raw DQL schema stringdirectly, giving full control over predicate types, indexes, and directives.
Engine.dropPredicate— deletes a single predicate (and its data) fromthe embedded engine via
posting.DeletePredicate.AltercarryingDropAttrroutes todropPredicate, so the embedded (file://) path matches a remote cluster'sDropAttrsemantics.The problem it solves
UpdateSchemainfers the schema from Go struct tags, which is convenient butcannot express predicates no Go type models yet — the common case during a
migration that adds or reshapes predicates ahead of the code.
AlterSchemaisthe escape hatch: hand Dgraph the exact DDL.
Dropping a predicate had a second gap: a remote cluster honors an
AlterwithDropAttr(delete one predicate and its data), but the embedded engine ignoredit. This wires the embedded path to
posting.DeletePredicate, so a single-predicate drop behaves the same in
file://anddgraph://modes.Tests
TestDropPredicateEmbeddedruns the full lifecycle — declare → insert →confirm present →
DropAttr→ confirm gone — against the embedded engine (andagainst a live cluster when
MODUSGRAPH_TEST_ADDRis set).The automated review (cubic) found no issues.
Documentation
A runnable
ExampleClient_alterSchemashowing predicate types, indexes, anddirectives applied directly.