# How to correctly alter a schema in DQL

**URL:** <https://discuss.dgraph.io/t/how-to-correctly-alter-a-schema-in-dql/12713>\
**Category:** Dgraph\
**Tags:** kind:question\
**Created:** [February 9, 2021, 11:20am UTC](https://discuss.dgraph.io/t/how-to-correctly-alter-a-schema-in-dql/12713 "2021-02-09T11:20:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vnium](https://avatars.discourse-cdn.com/v4/letter/v/e56c9b/32.png) [@vnium](https://discuss.dgraph.io/u/vnium)\
**Post date:** [February 9, 2021, 11:20am UTC](https://discuss.dgraph.io/t/how-to-correctly-alter-a-schema-in-dql/12713/1 "2021-02-09T11:20:09Z")

</div>

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:

```auto
predicate1: string .
predicate2: string .

type Type1 {
predicate1
predicate2
}

```

Next the schema is changed by adding `predicate3` and `Type2`:

Schema B:

```auto
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:

```auto
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:

```auto
predicate1: string .

type Type1 {
predicate1
}

```

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

I am using the Golang client.

---

<div class="post-metadata">

**Author:** ![MichelDiz](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/micheldiz/32/11873_2.png) [@MichelDiz](https://discuss.dgraph.io/u/MichelDiz)\
**Post date:** [February 10, 2021, 11:02pm UTC](https://discuss.dgraph.io/t/how-to-correctly-alter-a-schema-in-dql/12713/2 "2021-02-10T23:02:17Z")

</div>

> [@vnium](#):
>
> Is there a difference between only sending the updated part of a schema and sending a full new schema?

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.

> [@vnium](#):
>
> What should be sent to update the schema?

Each change can be a single call. Just fine.

> [@vnium](#):
>
> The complete schema B?

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

> [@vnium](#):
>
> Only Diff?

Yes. Best practice.

> [@vnium](#):
>
> Do the two methods result in a different schema?

No.

> [@vnium](#):
>
> Does a schema update automatically drop data?

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.

> [@vnium](#):
>
> For example Schema A is updated and `predicate2` is removed

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