Delete a predicate from schema (cont)

Hi there,

This is a continuation from the Delete a predicate from schema topic.

Quoting @tamethecomplex:

The conversation there indicates the issue was fixed in v0.8.0, but trying it out in v0.8.1 I still cannot see how to delete a predicate from the schema that negates the above statement. All predicates created seem to linger around forever in the schema.

Is there a solution for that in v0.8.1 as indicated, and if so what is it?

Hi @niemeyer

Deleting a predicate doesn’t automatically delete the schema entry associated with the predicate. What it does is it allows you to change the schema (from scalar <=> uid and vice versa).

Though now that I think about it we could delete the schema entry too and then it would be automatically derived from the next mutation for the predicate. I will make this part of the v0.8.2 release which goes out soon.

Hey @pawan,

Indeed the question (both mine and the original one) was specifically about how to delete predicates from the schema specifically.

I would suggest only deleting the entry from the schema if it has a default type. In other words, if we add any data we get an entry with a default type in the schema automatically, so sounds reasonable that if we remove it all again the schema entry is also gone.

That said, if we do have more specific schema definitions it would be surprising to see these definitions gone if the data is removed, since those were put in place independently via explicit actions.

More tersely, it would drop the predicate from the schema if:

  1. all data for a predicate is deleted and its schema has default type
  2. a schema mutation changes a predicate to default type, and there is no data using it

How does that sound?

Thanks @niemeyer.

The first point sounds good. It can also be deleted when the type is uid (and there are no reverse/count index on it), something that Dgraph assigns.

I suppose that is a workaround for deleting a predicate which has no data. I would prefer it to be more explicit. Maybe we could have a @delete directive for it which would only work if you have no data for the predicate.

Being completely explicit on the second case would be even better.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.