Update Types
We’re overhauling Dgraph’s docs to make them clearer and more approachable. If you notice any issues during this transition or have suggestions, please let us know.
You modify Dgraph types (node types and predicates types) by
- issuing a request to the
/alter
endpoint using the HTTP Client - using an
alter
operation of any DQL client library. - using Ratel UI
Notes about predicate type change
If data is already stored, existing values aren’t checked to conform to the updated predicate type.
On query, Dgraph tries to convert existing values to the new predicate type and ignores any that fail conversion.
If data exists and new indexes are specified, any old index not in the updated schema is dropped. New indexes are created.
Indexes in background
Indexes may take long time to compute depending upon the size of the data.
Indexes can be computed in the background and thus indexing may still be running after an Alter operation returns.
To run index computation in the background set the flag runInBackground
to
true
.
Notes
If executed before the indexing finishes, queries that require the new indices fail with an error notifying that a given predicate isn’t indexed or doesn’t have reverse edges.
In a multi-node cluster, it’s possible that the alphas finish computing indexes at different times. Alphas may return different schema in such a case until all the indexes are done computing on all the Alphas.
You can check the background indexing status using the
Health query on the
/admin
endpoint.
An alter operation fails if one is already in progress with an error
schema is already being modified. Please retry
.
Dgraph reports the indexes in the schema only when the indexes are done computing.
Deleting a node type
Type definitions can be deleted using the Alter endpoint.
Below is an example deleting the type Person
using the Go client:
Was this page helpful?