Skip to content

feat: AlterSchema, dropPredicate, and embedded DropAttr#24

Open
mlwelles wants to merge 1 commit into
matthewmcneely:mainfrom
mlwelles:feature/schema-ddl
Open

feat: AlterSchema, dropPredicate, and embedded DropAttr#24
mlwelles wants to merge 1 commit into
matthewmcneely:mainfrom
mlwelles:feature/schema-ddl

Conversation

@mlwelles

@mlwelles mlwelles commented Jun 4, 2026

Copy link
Copy Markdown

Adds raw schema-DDL primitives that complement UpdateSchema's object-template inference.

What

  • Client.AlterSchema(ctx, schema string) — applies a raw DQL schema string directly, giving full control over predicate types, indexes, and directives. Useful for schema 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 (file://) path matches a remote Dgraph cluster's DropAttr semantics.

Tests

TestDropPredicateEmbedded runs the full declare → insert → confirm-present → DropAttr → confirm-gone cycle against the embedded engine (and against a live cluster when MODUSGRAPH_TEST_ADDR is set).


Summary by cubic

Add raw schema DDL support via AlterSchema and implement DropAttr handling for the embedded engine to match remote Dgraph behavior. This enables precise schema migrations and safe single-predicate drops across embedded and remote modes.

  • New Features
    • Client.AlterSchema(ctx, schema) applies raw Dgraph schema directly, bypassing UpdateSchema inference (full control over types, indexes, directives).
    • Embedded Alter with DropAttr deletes a predicate and its data by routing to engine dropPredicate, mirroring cluster semantics.
    • Engine adds dropPredicate using posting.DeletePredicate.

Written for commit bd16559. Summary will update on new commits.

Review in cubic

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.
@mlwelles mlwelles requested a review from matthewmcneely as a code owner June 4, 2026 20:11

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 4 files

Re-trigger cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant