QuickStart Modifying schema
Modify graph schema.
About this task
Schema can be modified after creation, adding properties with addProperty()
and alter()
and dropping any element, property, vertex label, edge label, or index with drop()
.
Edge label alterations can additionally specify the pair of vertex labels on which the modification is accomplished.
The data type of a property, however, cannot be changed, without removing and recreating the property.
In addition, metadata about the vertex labels and edge labels can be dropped. If a vertex label’s metadata is dropped, the underlying table remains, but the label is removed along with any associated edge tables. Similarly, if an edge label’s metadata is dropped, the underlying edge label tables remain, but the connections to any vertex labels are dropped. Dropping all metadata removes all vertex labels and edge labels, but the underlying CQL tables remain, but are not associated with the graph.
Procedure
-
Drop properties
-
Drop the edge property:
schema.edgeLabel('authored'). dropProperty('one'). dropProperty('two'). alter()
or if you want to drop a property on an edge label for a specific connection between two vertex labels:
schema.edgeLabel('authored'). from('person'). to('book'). dropProperty('one'). dropProperty('two'). alter()
The latter variation is useful when an edge label is defined between more than one set of vertex labels. For instance, if both
person->authored->book
andperson->authored->blog
existed, then the expanded command would only drop the properties fromperson->authored->book
. -
Drop vertex labels, edge labels, or indexes
-
Drop a particular index:
schema.vertexLabel('person'). materializedView('person_by_gender'). ifExists(). drop()
See Dropping graph schema for complete information.
-
Drop a property from a search index:
schema.vertexLabel('store'). searchIndex(). dropProperty('name'). alter()
-
Drop a particular vertex label:
schema.vertexLabel('person'). ifExists(). drop()
Edge labels can be dropped similarly. See Dropping graph schema for complete information.
-
Drop metadata
-
Drop all metadata for all vertex labels and edge labels:
schema.dropMetadata()