How to correctly alter a schema in DQL

Question 1: Is there a difference between only sending the updated part of a schema and sending a full new schema?

For example the following schema exists:

Schema A:

predicate1: string .
predicate2: string .

type Type1 {
predicate1
predicate2
}

Next the schema is changed by adding predicate3 and Type2:

Schema B:

predicate1: string .
predicate2: string .
predicate3: string .

type Type1 {
predicate1
predicate2
}

type Type2 {
predicate3
}

So the change difference between Schema A and Schema B is:
Diff:

predicate3: string .

type Type2 {
predicate3
}

What should be sent to update the schema? The complete schema B? Only Diff? Do the two methods result in a different schema?


Question 2: Does a schema update automatically drop data?

For example Schema A is updated and predicate2 is removed, resulting in Schema C:
Schema C:

predicate1: string .

type Type1 {
predicate1
}

Does data for predicate2 get automatically dropped when sending the schema modification?

I am using the Golang client.

No, you can send small changes to the Alter endpoint.
But not sure what you mean. Send a “full new schema”? Do you mean a full update? or a different, therefore new schema? If the second, both will coexist in the schema(you should cleanup the DB otherwise). Thus, they will be a single schema. If you wanna have “virtually different schemas” in the same DB. I recommend that you prefix your predicates. E.g: “schema1.name: string . schema2.name: string .” This way they will be unique, not shared.

Each change can be a single call. Just fine.

No, add new predicates and types isn’t necessary to send the whole schema again.

Yes. Best practice.

No.

No, it is not possible to drop the data by changing the schema. First of all, Dgraph won’t let you made mistakes. You can’t, for example, rename a predicate by force. You have to do a migration with an upsert block.

You can’t remove a predicate by editing the schema. The only way is by an operation called “drop attribute”.